Cam*_*zco 4 ruby-on-rails devise ruby-on-rails-3
我正在尝试使用设计恢复用户的密码,但它会生成以下错误
undefined method `reset_password_sent_at=' for #<User:0x007fb78cfafb68>
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我,因为我是Ruby on Rails的新手?
使用Devise恢复密码和向用户发送电子邮件的最佳方法是什么?非常感谢你...
我用的是装饰(2.2.3)
User.rb
require 'digest/md5'
class User < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model
belongs_to :shop
before_create :compute_email_md5
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
:recoverable,
:rememberable,
:trackable,
:validatable,
:token_authenticatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email,
:email_md5,
:password,
:password_confirmation,
:shop_id,
:role,
:terms,
:name,
:notify_on_order_received
validates :terms, :acceptance => true, :on => :create
end
Run Code Online (Sandbox Code Playgroud)
解决方案是将reset_password_sent_at列添加到用户表
正如您所发现的,passord恢复要求模型具有reset_password_sent_at列.通过迁移添加它应该可以解决这个问题.
至于发生这种情况的原因,我猜你在最初生成启用Devise的模型(用户)之后添加了密码恢复(:recoverable模块).这就是为什么Devise的发生器没有为你创建那个专栏的原因.
| 归档时间: |
|
| 查看次数: |
719 次 |
| 最近记录: |