Setup using a simple example: I\'ve got 1 table (Totals) that holds the sum of the amount column of each record in a second table (
From Rails 5.1, the behavior of attribute_was inside of after callbacks have change. attribute_was will return the value after the save is done and return the current value in an after_save or after_update callback.
attribute_before_last_save is invoked two ways to get the previous value of a field in the after_save and after_update callbacks right now:
Option #1
attribute_before_last_save('yourfield')
Option #2
*_before_last_save