Using ActiveRecord to call the after_save callback every time the save method even if the model has not been changed and there is no insert / update request generated.
ActiveRecord performs: after_save callbacks each time a record is successfully saved regardless of its change.
# record invalid, after_save not triggered Record.new.save
What you want to know is changing the record, not saving the record. Can you easily accomplish this using record.changed?
class Record after_save :do_something_if_changed protected def do_something_if_changed if changed? # ... end end end
source share