Windows 8.1 Rails 4.1 Ruby 2.0.0
这就是我在user.rb(模型)中的内容:
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:password_expirable, :confirmable, :lockable, :timeoutable
if :work_phone != nil
phony_normalize :work_phone, :default_country_code => 'US'
end
if :mobile_phone != nil
phony_normalize :mobile_phone, :default_country_code => 'US'
end
if :fax_phone != nil
phony_normalize :fax_phone, :default_country_code => 'US'
end
if :other_phone != nil
phony_normalize :other_phone, :default_country_code => 'US'
end
validates :first, presence: true
validates :last, presence: true
validates :organization, presence: true
validates_plausible_phone :work_phone
validates_plausible_phone :mobile_phone
validates_plausible_phone :fax_phone
validates_plausible_phone :other_phone
validates :email, :email => true, presence: true, uniqueness: {case_sensitive: false}
before_save { |user| user.email = email.downcase }
end
这就是我在我的种子中所拥有的.rb:
user = User.new(
:email =>'test@acme.net',
:password =>'Vb%69Krn#',
:password_confirmation =>'Vb%69Krn#',
:first =>'John',
:last =>'Doe',
:salutation =>'Doe',
:organization =>'Doe Test',
:work_phone =>'555-555-5555',
:mobile_phone =>'555-555-5555',
:fax_phone =>'555-555-5555',
:other_phone =>'555-555-5555',
:address1 =>'One Main Street',
:city =>'Anytown',
:state =>'WA',
:zip =>'98011',
:role =>'admin'
)
user.skip_confirmation!
user.save
当我执行rake db:seed时,我收到以下错误消息:
rake aborted!
NoMethodError: undefined method `password_changed_at_changed?' for #<User:0x00000005f2b458>
C:/projects/rails/doe/db/seeds.rb:27:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
Tasks: TOP => db:seed
有什么想法吗?
答案 0 :(得分:1)
这是devise_security_extension的问题。您已设置password_expirable
,但您可能没有这样做:
create_table :the_resources do |t|
# other devise fields
t.datetime :password_changed_at
end
add_index :the_resources, :password_changed_at
正如the documentation中所述。