ActiveRecord allows you to view saved changes
Say you have an Activerecord object that you are making changes to.
user = User.last
user.update(first_name: "Joe", last_name: "Hashrocket")
With ActiveModel's Dirty
module, you can view the changes made to the model even after it has been saved using the saved_changes
method
user.saved_changes
# {"first_name"=>[nil, "Joe"], "last_name"=>[nil, "Hashrocket"]]}
Tweet