I'm using rails
with devise
confirmable
.
Generally I want to have users confirm their email address, however sometimes I need to manually change an email on behalf of an existing user and I want to skip sending the confirmation email.
When creating a new user I can skip the confirmation email with:
user.skip_confirmation!
...but this does not appear to work for existing, already confirmed users - insofar as the email attribute is not updated, and devise
still requires the user to confirm the new email and sends out a confirmation email:
@user = User.find_by_email('bob@site.example')
@user.email = 'dead@site.example'
@user.skip_confirmation!
@user.save!
The method you want to use is skip_reconfirmation!
(note the 're' in reconfirmation).
@user = User.find_by_email('bob@site.example')
@user.email = 'dead@site.example'
@user.skip_reconfirmation!
@user.save!