plataformatec/devise — Issue #1456: Confirmable bug with key other than :email
Author: tomschlenkhoff
Created: 2011-11-23 16:33:53+00:00
State: open

Running devise 1.5.1 with Rails 3.1.3
Set up devise to use :account_email as confirmation/reset/unlock key - instead of the usual :email
Everything is working nicely, but:

When a user already has confirmed her account and she clicks on "Didn't receive confirmation instructions?" aka "http://localhost/users/confirmation/new" I get a

NoMethodError in Devise::ConfirmationsController#create

undefined method `email' for #

with the top of the trace being:
activemodel (3.1.3) lib/active_model/attribute_methods.rb:385:in `method_missing'
activerecord (3.1.3) lib/active_record/attribute_methods.rb:60:in `method_missing'
activemodel (3.1.3) lib/active_model/errors.rb:310:in `generate_message'
activemodel (3.1.3) lib/active_model/errors.rb:217:in `add'
devise (1.5.1) lib/devise/models/confirmable.rb:113:in `unless_confirmed'
devise (1.5.1) lib/devise/models/confirmable.rb:55:in `resend_confirmation_token'
devise (1.5.1) lib/devise/models/confirmable.rb:142:in `send_confirmation_instructions'

I expect the error to be here:

lib/devise/models/confirmable.rb:113:in `unless_confirmed'

because when I exchange :email against :account_email here, everything is fine and dandy. I just don't know how to write it so that it works with every resource. Hope this helps!