-
Notifications
You must be signed in to change notification settings - Fork 898
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
Reified record cannot be persisted if associated record has been deleted #841
Comments
Hi Sergey, good question. Thanks for testing reification of associations. This is an experimental feature and not recommended for production. If I understand correctly, when you try to Currently, # lib/paper_trail/reifier.rb:280
without_persisting(child) do
model.send "#{assoc.name}=", child
end As a workaround, you could try to manually save the reified_stadium = PaperTrail::Version.find(2594).reify
reified_user = reified_stadium.user.dup # dup to clear the id
reified_user.save
reified_stadium.user = reified_user
reified_stadium.save Of course, this is awkward for you and it would be nice if PT had this feature. I would be happy to review a PR that adds this feature. |
However we implement this new feature, Unrelated, but worth mentioning: When users of PT reify and then subsequently persist a record, both operations must occur within a single transaction, to avoid phantom read errors. |
329e224 adds this to the list of known issues. |
Hello Jared & Sergey, what about using I wrote simple test to see how it works.
|
Hi Hubert, thanks for the suggestion. I've incorporated your tests into So, for now, I guess we advise people to use Do y'all want to close this issue, or should we maybe discuss the reify API? For example, maybe flags like |
I talked about this with my team a while back. We were thinking of a
|
Closing due to inactivity. I am thinking more and more of deleting the experimental association-tracking feature. No one is stepping up to fix the known issues, and I'm not even sure some of them, like #542 can be fixed. Maybe I should deprecate it in 9.0.0 and see who steps up and volunteers to take care of it. |
Closes paper-trail-gem#841, hopefully
Let's say I have
StadiumUser
model that has_oneStadium
, and the dependency between them is like that:I created StadiumUser and the Stadium with it. Then I decided to delete StadiumUser, and Stadium was deleted with it. Okay.
Then I decided to revert that model:
This situation also crashes rails_admin_history_rollback gem, when I am trying to revert a model that links to deleted entry, it displays the same error message.
Can something be done with that?
The text was updated successfully, but these errors were encountered: