Add to the Devise initializer:
config.send_email_changed_notification = true
Use this PR for attr_encrypted
gem 'attr_encrypted', github: 'Countable-us/attr_encrypted', branch: 'active-record-5.2'
Add this to your model
class User < ApplicationRecord
def send_email_changed_notification
send_devise_notification(:email_changed, to: email_was)
end
end
Thank you very much for your precious help.
I set
config.send_email_changed_notification = true
and follow all the steps!But I still get the error: " ArgumentError: SMTP To address may not be blank"
I think because of "Confirmable" Devise module. When I try to change the email, the new email is set on 'unconfirmed_email' field and the "encrypted_email" field is set to blank (this cause the error IMHO). Just when the new email is confirmed, the "encrypted_mail" is filled with the new email.
Thank you for your help!