instance method
saved_change_to_attribute
Ruby on Rails 7.2.3
Since v5.2.8.1Signature
saved_change_to_attribute(attr_name)
Returns the change to an attribute during the last save. If the attribute was changed, the result will be an array containing the original value and the saved value.
This method is useful in after callbacks, to see the change in an attribute during the save that triggered the callbacks to run. It can be invoked as saved_change_to_name instead of saved_change_to_attribute("name").
Parameters
-
attr_namereq
Source
# File activerecord/lib/active_record/attribute_methods/dirty.rb, line 98
def saved_change_to_attribute(attr_name)
mutations_before_last_save.change_to_attribute(attr_name.to_s)
end
Defined in activerecord/lib/active_record/attribute_methods/dirty.rb line 98
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::AttributeMethods::Dirty