Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4616

How to revert/undo local changes to an Activerecord object?

$
0
0

Is there a way to undo/revert any local changes to an Activerecord object. For example:

user = User.firstuser.name # "Fred"user.name = "Sam"user.name_was # "Fred"user.revertuser.name # "Fred"

I know I could do user.reload but I shouldn't have to hit the database to do this since the old values are stored in the state of the object.

Preferably a Rails 3 solution.


Viewing all articles
Browse latest Browse all 4616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>