2013-02-19 42 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的發電機沒有爲你創造這個專欄。