undefined method `confirmed_at=' for #<User:0x...>

1,143 views
Skip to first unread message

jan0sch

unread,
Jul 2, 2010, 5:58:00 AM7/2/10
to Devise
Hi,

I created a rails project using ruby-1.9.2-head, rails 3 beta4 and
devise 1.1.rc2 and followed the instructions from the readme. When
visiting http://localhost:3000/users/sign_up I get the following error
message after filling out the form and sending it:

NoMethodError in Devise/registrationsController#create
undefined method `confirmed_at=' for #<User:0x0000000393d9a8>

Regards,

Jens

jan0sch

unread,
Jul 2, 2010, 7:34:31 AM7/2/10
to Devise
I just re-created a clean rails project and it works now. If I'm able
to reproduce the bug above I'll file a bug report.

Alan Kucheck

unread,
Jul 7, 2010, 2:19:58 AM7/7/10
to Devise
I have just added :confirmable to an existing project. While the app
works fine, my Cucumber tests fail with:
undefined method `confirmed_at=' for #<User:0x1033a8730>
(NoMethodError)
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/benchmark.rb:308:in `realtime'
./features/step_definitions/authentication_steps.rb:30:in `/^I sign up
as a new member$/'
features/authentication.feature:34:in `And I sign up as a new member'

Failing Scenarios:
cucumber features/authentication.feature:30 # Scenario: a Visitor
Signs Up

Has anyone else encountered this?

thanks,

ak

On Jul 2, 2:58 am, jan0sch <jens.jah...@googlemail.com> wrote:
> Hi,
>
> I created a rails project using ruby-1.9.2-head, rails 3 beta4 and
> devise 1.1.rc2 and followed the instructions from the readme. When
> visitinghttp://localhost:3000/users/sign_upI get the following error

Alan Kucheck

unread,
Jul 10, 2010, 6:01:59 PM7/10/10
to Devise
Newbie error: forgot to migrate test environment. Once that is done,
all is well again.

My apologies for the disturbance.

thanks,

ak

On Jul 6, 11:19 pm, Alan Kucheck <akuch...@gmail.com> wrote:
> I have just added :confirmable to an existing project. While the app
> works fine, my Cucumber tests fail with:
> undefined method `confirmed_at=' for #<User:0x1033a8730>
> (NoMethodError)
> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
> 1.8/benchmark.rb:308:in `realtime'
> ./features/step_definitions/authentication_steps.rb:30:in `/^I sign up
> as a new member$/'
> features/authentication.feature:34:in `And I sign up as a new member'
>
> Failing Scenarios:
> cucumber features/authentication.feature:30 # Scenario: a Visitor
> Signs Up
>
> Has anyone else encountered this?
>
> thanks,
>
> ak
>
> On Jul 2, 2:58 am, jan0sch <jens.jah...@googlemail.com> wrote:
>
> > Hi,
>
> > I created a rails project using ruby-1.9.2-head, rails 3 beta4 and
> > devise 1.1.rc2 and followed the instructions from the readme. When
> > visitinghttp://localhost:3000/users/sign_upIget the following error
Message has been deleted

Reza.Hashemi

unread,
Jul 15, 2010, 6:08:09 PM7/15/10
to Devise
That is because you have forgotten to uncomment t.confirmable in
initial devise migartion, in that case the
confirmable model does not know confirmed_at attribute and the
following method in device/model/confirmable.rb raises error.

# Generates a new random token for confirmation, and stores
the time
# this token is being generated
def generate_confirmation_token
self.confirmed_at = nil
self.confirmation_token = self.class.confirmation_token
self.confirmation_sent_at = Time.now.utc
end

Check your db/shema.rb to see if there is a confirmed_at field or not.

To solve this, you can re-create your devise model with correct
migration (as you did) or create another migration to modify current
devise model:

rails g migration addconfirmable

then change the migration file as follows: (account is my devise model
in this case, use yours instead)

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

rake db:migrate

It should work now.

Regards
-Reza

Reza.Hashemi

unread,
Jul 15, 2010, 6:27:26 PM7/15/10
to Devise
also add unique index before end:
add_index :accounts, :confirmation_token, :unique => true

Reply all
Reply to author
Forward
0 new messages