LendingHome / active_record-updated_at

Touch `updated_at` by default with calls to `update_all` and `update_column(s)`
MIT License
26 stars 5 forks source link

Firing callbacks with update_column #4

Closed farnoy closed 7 years ago

farnoy commented 7 years ago

Hi there, thanks for your work on this great little gem.

I was wondering if you might add support for AR callbacks with update_column. For some unexpected reason, they are not fired and I need code like below to fire my callbacks (I have a lot of them).

  User.find(123).update_column(name: "Sean")
ximus commented 7 years ago

The method update_column is there for the very purpose of skipping the activerecord model stack (including callbacks). If you want callbacks invoked, I'm afraid you are going to have to update your update_column calls to update_attribute. I'm not aware of any plans to modify update_column to invoke callbacks.

shuber commented 7 years ago

@farnoy Thanks! Agree with @ximus on this one, that is not something we plan on introducing to this gem. Doing a mass find and replace of update_column to update_attribute would probably be a quick and easy solution to your problem.