instance method
saved_change_to_attribute?
Ruby on Rails 7.0.10
Since v5.2.8.1Signature
saved_change_to_attribute?(attr_name, **options)
Did this attribute change when we last saved?
This method is useful in after callbacks to determine if an attribute was changed 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").
Options
from-
When specified, this method will return false unless the original value is equal to the given value.
to-
When specified, this method will return false unless the value will be changed to the given value.
Parameters
-
attr_namereq -
optionskeyrest
Source
# File activerecord/lib/active_record/attribute_methods/dirty.rb, line 80
def saved_change_to_attribute?(attr_name, **options)
mutations_before_last_save.changed?(attr_name.to_s, **options)
end
Defined in activerecord/lib/active_record/attribute_methods/dirty.rb line 80
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::AttributeMethods::Dirty