1
votes

I would like to change a simple attribute to the user after they change their password.

I have an attribute on users called "password_changed" with a default of false, but would like to change this to true after they change their password. Is the only way to do this to create a custom Devise password edit? Like this (https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-password). Or can I extend the update method on the devise registrations controller with something like:

def update
current_user.password_changed = true
current_user.save
end
1

1 Answers

0
votes

You can use a after_save callback for your User model:

after_save :password_changed_callback, if: Proc.new { |record| record.persisted? && record.password_changed? }