Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rollback method to ActiveModel::Dirty #14861

Merged
merged 1 commit into from Jun 30, 2014

Conversation

igor04
Copy link
Contributor

@igor04 igor04 commented Apr 24, 2014

Maybe I have missed something but looks like rollback changes should be presented here

@estsauver
Copy link
Contributor

estsauver commented Apr 27, 2014

Hey @igor04

What's the difference between this and reset_changes? Am I missing something? It looks to me like they both do the same things?

~Earl

@igor04
Copy link
Contributor Author

igor04 commented Apr 27, 2014

Hi @estsauver

Not exactly, reset_changes - when you want to reset the changes information not rollback value, just delete information about changes. After reset_changes attribute will have new value but it will look like attribute has not been changed (because data about changes is deleted).

@timraymond
Copy link
Contributor

timraymond commented Jun 21, 2014

@igor04 So reset_changes will only make it appear as though nothing has changed, even though any changes that you've made still stick around? If that's the case, I'd say this patch is a win.

@@ -176,6 +188,11 @@ def reset_changes
@changed_attributes = ActiveSupport::HashWithIndifferentAccess.new
end

# Restore all previous data
def rollback_changes
changed.each { |attr| reset_attribute! attr }
Copy link
Contributor

@sgrif sgrif Jun 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should call changed_attributes.each_key, changed gets overridden by ActiveRecord::AttributeMethods::Dirty to include in-place mutations.

@rafaelfranca rafaelfranca merged commit 552d4d8 into rails:master Jun 30, 2014
rafaelfranca added a commit that referenced this pull request Jun 30, 2014
Added rollback method to ActiveModel::Dirty
@igor04 igor04 deleted the dirty-rollback branch Jul 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants