-
Notifications
You must be signed in to change notification settings - Fork 899
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
Has Many Through Association via has_many: and belongs_to: on the join table #590
Comments
Currently,
What PaperTrail methods are you using? |
Bad copy/paste, sorry. I'm using paper trail 4.0.0, although same result with using master from git.
This last line fails, in the rails console in development mode, with a Note, if I stick that wrap that code in a test, it runs, however, the previous version of the document returns an empty list of sections. |
I can't reproduce this issue. Please review the test app I created (https://github.com/jaredbeck/pt_issue_590) and propose (via a PR to the test app) a change which will reproduce the issue. Thanks. |
For me, there are two distinct issues. In test mode, behaviour is different than from the console. In test, the old version no longer has the associations - test app shows this. But the crash, I only get in console. I don't know how to reproduce in test mode (I think it would crash there too, if the associations were not lost). Here is the code reproducing the issue in console: From the console:
last line fails with the below. Happy to provide more info/test, let me know what is needed. NoMethodError: undefined method |
If I merely remove the has_many :paragraphs, through: :sections from document, then it no longer crashes in console - this is something I'm happy to leave for my app. Difference between test and dev environment is still there. I've sent you another pull request for a simpler case (no paragraphs) which still shows the children missing on a previous version in test environment. |
Yes, it's not currently possible to test reification of associations when Regarding the
By setting
I'm glad that workaround is OK for you, but I believe it is our goal to support |
I've added a warning to the readme: ce37034 |
The issue is at this line: https://github.com/airblade/paper_trail/blob/master/lib/paper_trail/version_concern.rb#L420 collection_keys should collect the list of all the records that are associated with has_many through relationship. ( The present code only works for belongs_to association). Fixed the issue in theRealNG@5bcfb86 Will test it throughly and place a pull request |
Fixed by #596, closing. |
Is it really fixed? I came across this. Maybe we can delete it from the known issue if it is? |
Hi Benjamin. This issue (#590) was fixed by #596 and released in PT 4.1.0. You are looking at the docs for 4.0. The docs for 4.1 (https://github.com/airblade/paper_trail/blob/4.1-stable/README.md) do not mention #590. |
Hi Jared. Ah ok, thanks for your answer! I still have problems with associations with the 4.1.0 and the master version. If I can pin down the problem I will post an issue. |
I'm reopening #530 (#530) as I'm facing the same issue and don't believe the reference #466) addresses it (Or if it does, I've completely failed to understand)
Paper_Trail 4.0.0 Beta doesn't cater this situation. It looks for foreign key of association Paragraph i.e, section_id in the through model i.e, Section which will not be available in the above mentioned case.
#466 mentions adding an additional column to 'versions' table. However, the data is already there. With the existing code, a query on section can already return its paragraphs and revisions.
[If anything, may I suggest a note in the Readme that this case is not supported?]
Thanks
André
The text was updated successfully, but these errors were encountered: