Skip to content

Added rollback method to ActiveModel::Dirty - #14861

Merged
rafaelfranca merged 1 commit into
rails:masterfrom
igor04:dirty-rollback
Jun 30, 2014
Merged

Added rollback method to ActiveModel::Dirty#14861
rafaelfranca merged 1 commit into
rails:masterfrom
igor04:dirty-rollback

Conversation

@igor04

@igor04 igor04 commented Apr 24, 2014

Copy link
Copy Markdown
Contributor

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

@estsauver

Copy link
Copy Markdown
Contributor

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

igor04 commented Apr 27, 2014

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor

@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.

Comment thread activemodel/lib/active_model/dirty.rb Outdated

Copy link
Copy Markdown
Contributor

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 July 1, 2014 09:58
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.

6 participants