Adam Klein
2013-Aug-21 22:57 UTC
Feature Request - Add model_was and revert_changes to ActiveModel::Dirty
I''ve encountered a need to use the previous state of the model, before all the changes were made. I fantasized about something like: model.was or model.before_changes Also, a nice method to have is ''revert_changes'', that reverts all the changes (without reloading the model from DB). Alternatively: revert_changes would be the first method I suggested (reverting changes without changing the object), and: revert_changes! would be the second one (reverting changes on the object itself). I would like to make a pull request. implementing the second one is easy - I just loop through changes and undo them. First one is harder because we need another instance of the model, maybe I''ll use ''dup'' method? ideas, thoughts? Thanks -- 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 rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.