Hi,
I've encountered a need to see the model's state before all the changes
that were made to it.
I fantasized on something like this:
"model.was"
or
"model.before_changes"
Also, I would like to have an option to revert all changes without
reloading from DB. Something like:
"model.revert_changes"
I want to make a pull request with the following solution:
def was
result = self.dup.tap { |model| model.id <http://o.id/> = self.id }
self.changes.each {|attr, values| result[attr] = values[0]}
result
end
def revert_changes
self.changes.each {|attr, values| self[attr] = values[0]}
end
Any thoughts on the subject?
- Regards,
-- Adam Klein
--- 500tech.com
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.