How to hook into model attribute changes?

Hi John


What's the best way to hook into any changes made to the value of a
single model attribute? I need to know when the encrypted_password
attribute on my User model changes i.e. when the user has changed their
password. I'm not interested in the actual changed value, I just need to
know when it's been changed so that I can regenerate their API key as

cch: You should look into callbacks. For example, I use

  def after_update(record)
    log(record, "UPDATE")

to record whether a change has been made

You could try using this plugin and a callback (after_update maybe?)
to determine when to regenerate the API key: