2013-02-19 47 views
4

我试图用色器件恢复用户的密码,但它会生成以下错误如何恢复密码与设计(Ruby on Rails的)

undefined method `reset_password_sent_at=' for #<User:0x007fb78cfafb68> 

谁能帮助我,因为我m新的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 

的解决方案是 reset_password_sent_at列到用户表

+0

版本的设计?你能显示一些代码吗? – Nobita 2013-02-19 16:29:49

+0

好的我'使用设计2.2.3 – 2013-02-19 16:36:42

+0

请显示你正在使用设计的模型。 – Nobita 2013-02-19 16:41:05

回答

5

由于添加你已经发现,passord恢复要求该模型有一个reset_password_sent_at列。通过迁移添加它可以解决这个问题。

至于原因发生这种情况,我猜你添加密码恢复(在:recoverable模块)最初产生启用了设计模型(用户)。这就是为什么Devise的发电机没有为你创造这个专栏。