Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined local variable or method `confirmed_at' for #User

Tags:

I am using Rails 3. There is a possible duplicate here. But it did not solve my problem, neither did any other solution.

My migration is as follows

class AddConfirmableToDevise < ActiveRecord::Migration   def change     change_table(:users) do |t|        t.confirmable      end     add_index  :users, :confirmation_token, :unique => true    end end 

I do have devise :confirmable added in User model.

My rake db:migrate gives no output. and my sign up page gives the error:

undefined local variable or method 'confirmed_at' for #User 

Anybody has a clue?

like image 781
hrishikeshp19 Avatar asked Feb 02 '12 07:02

hrishikeshp19


2 Answers

Ok. I solved it. The migration is outdated. Generate new migration with same code but another name.

1.Run command:

rails g migration add_confirmable_to_devise_v1 

2.In the migration file:

class AddConfirmableToDeviseV1 < ActiveRecord::Migration   def change     change_table(:users) do |t|        t.confirmable      end     add_index  :users, :confirmation_token, :unique => true    end end 

3.Then

rake db:migrate 
like image 87
hrishikeshp19 Avatar answered Sep 22 '22 15:09

hrishikeshp19


As of the latest devise, you just need to remove comments from the following lines on the devise users migration.. (2013....._devise_create_users.rb)

  # Confirmable   t.string   :confirmation_token   t.datetime :confirmed_at   t.datetime :confirmation_sent_at   t.string   :unconfirmed_email # Only if using reconfirmable 
like image 37
SomeDudeSomewhere Avatar answered Sep 24 '22 15:09

SomeDudeSomewhere