instance method
previous_changes
Ruby on Rails 5.2.8.1
Since v3.0.20Signature
previous_changes()
Returns a hash of attributes that were changed before the model was saved.
person.name # => "bob" person.name = 'robert' person.save person.previous_changes # => {"name" => ["bob", "robert"]}
Source
# File activemodel/lib/active_model/dirty.rb, line 246
def previous_changes
@previously_changed ||= ActiveSupport::HashWithIndifferentAccess.new
@previously_changed.merge(mutations_before_last_save.changes)
end
Defined in activemodel/lib/active_model/dirty.rb line 246
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::Dirty