Devise: Changing the :email field directly with (re)confirmable enabled?

Created on 6 Mar 2013  路  1Comment  路  Source: heartcombo/devise

I checked the source and didn't find a solution. Hopefully this can be a feature or there is already a way that I missed.

I want confirmable and reconfirmable to be on my User model by default, but I also want administrators the ability to directly change the :email attribute without first setting it then manually calling confirm!. One reason for this is it takes an addition UPDATE query and it's also mucking with the change tracking I have on the model (paper_trail).

This is currently how I have to change emails with reconfirmable on:

user = User.find(name: 'foo').first
user.email # => [email protected]
user.email = "[email protected]"
user.save
user.email # => [email protected]
user.unconfirmed_email # => [email protected]
user.confirm!
user.email # => [email protected]
user.unconfirmed_email # => nil

Even if I have to set a flag first, I'd like to be able to set the email, save it, and skip the confirmable. It looks like #skip_confirmation! does not work for updating emails.

Most helpful comment

I'm an idiot, I looked forever and probably overlooked this method a dozen times. #skip_reconfirmation! is exactly what I was looking for. Sorry!

>All comments

I'm an idiot, I looked forever and probably overlooked this method a dozen times. #skip_reconfirmation! is exactly what I was looking for. Sorry!

Was this page helpful?
0 / 5 - 0 ratings