Method: ActiveRecord::AttributeMethods::Dirty#attribute_before_last_save
- Defined in:
- lib/active_record/attribute_methods/dirty.rb
#attribute_before_last_save(attr_name) ⇒ Object
Returns the original value of an attribute before the last save.
This method is useful in after callbacks to get the original value of an attribute before the save that triggered the callbacks to run. It can be invoked as name_before_last_save
instead of attribute_before_last_save("name")
.
108 109 110 |
# File 'lib/active_record/attribute_methods/dirty.rb', line 108 def attribute_before_last_save(attr_name) mutations_before_last_save.original_value(attr_name.to_s) end |