Fixes an exception when a has_one association is recursively restored.#118
Closed
stupergenius wants to merge 1 commit into
Closed
Fixes an exception when a has_one association is recursively restored.#118stupergenius wants to merge 1 commit into
stupergenius wants to merge 1 commit into
Conversation
Collaborator
|
Hi @stupergenius, could you please write a regression test for this? |
Contributor
|
Am I correct in thinking that the case of a nullable single collection should also be handled? i.e., if association_data is nil, currently restore fails. My additional fix, off the top of my head, probably wrong: ...
association_data = send(association.name)
unless association_data.nil?
if association_data.paranoid?
if association.collection?
association_data.only_deleted.each { |record| record.restore(:recursive => true) }
... |
Contributor
|
The nil check seems to fix the remaining issue. I've made a new pull request with the combined fix. |
pobocks
added a commit
to pobocks/paranoia
that referenced
this pull request
Mar 7, 2014
* Based on partial fix by @stupergenius * Handles nil case for hasOne associations
pobocks
added a commit
to harvard-library/inscriptio
that referenced
this pull request
Mar 7, 2014
radar
added a commit
that referenced
this pull request
Mar 11, 2014
Regression tests and full fix for #118
radar
pushed a commit
that referenced
this pull request
Mar 11, 2014
* Based on partial fix by @stupergenius * Handles nil case for hasOne associations Fixes #119
Collaborator
|
Fixed by #119. |
pobocks
added a commit
to harvard-library/inscriptio
that referenced
this pull request
Mar 13, 2014
pobocks
added a commit
to harvard-library/inscriptio
that referenced
this pull request
Apr 7, 2014
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.
The original implementation would raise a
method_missingexception when a has_one association was recursively restored. The pull request first checks to see if the association is a collection before looping through the deleted items.