clear rolled back versions from associated model#440
Merged
batter merged 4 commits intopaper-trail-gem:masterfrom Nov 11, 2014
moserrya:master
Merged
clear rolled back versions from associated model#440batter merged 4 commits intopaper-trail-gem:masterfrom moserrya:master
batter merged 4 commits intopaper-trail-gem:masterfrom
moserrya:master
Conversation
Collaborator
|
I think this makes sense.. I'm guessing the concern here is a failure on the first update, then a second update going through and a version being persisted for a state change that never happened? Any chance you can add some tests? |
Contributor
Author
|
This is exactly the concern. I will add tests. |
batter
added a commit
that referenced
this pull request
Nov 11, 2014
Collaborator
|
Cheers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I propose this change to fix an issue where, under the right circumstances, version records are created for changes that never took place. Let's say I have two models,
ItemandLocation, and attempt to save changes in a transaction:The
Itemmodel herehas_paper_trail. A version is created for the item'supdate_attributes!call is created and then rolled back, as expected. However, if we rescue from the error that happens when we runLocation.first.update_attributes!and then callitem.save, the rolled back version created when we tried to update the sku in a transaction is also saved - even though the sku on the item is not changed.An alternative approach - could try setting
autosave: falseinhas_paper_trail