rspec user test gives “undefined local variable or method `confirmed_at' ”

青春壹個敷衍的年華 提交于 2019-12-05 09:45:51

Looks like you missed the "confirmable" configuration for Devise somewhere along the way. You can add the three missing columns yourself or try something like this (see Reza.Hashemi's message near the bottom of this thread:

$ rails g migration addconfirmable

Then edit the migration to this:

def self.up 
  change_table(:users) do |t| 
    t.confirmable 
  end 
end 

and finally, the usual:

$ rake db:migrate

I think the above process should add your three columns:

  • confirmed_at :datetime
  • confirmation_token :string
  • confirmation_sent_at :datetime

for you. Or you can do it by hand.

For Mongoid, look in the user model -- the needed fields may be commented out. For me, they were:

## Confirmable
field :confirmation_token,   :type => String
field :confirmed_at,         :type => Time
field :confirmation_sent_at, :type => Time
field :unconfirmed_email,    :type => String # Only if using reconfirmable
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!