-
Notifications
You must be signed in to change notification settings - Fork 901
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
Papertrail does not delete properly when combined with Paranoia #593
Comments
I think it should work fine, although I will say that it seems sort of redundant to use Paranoia and PaperTrail in conjunction while recording If you want to continue using both plugins in conjunction with each other, it may benefit you to just have PaperTrail skip creating a version for |
Hi, just throwing in some more information on this topic: |
Instead of making PaperTrail more complicated by adding configuration options, I'd prefer to make PaperTrail less complicated by allowing users to add the callbacks themselves. This is what libraries like CanCanCan and Pundit do. I suggested something similar back in June: #556 I would be happy to review a PR that gives users control over the order of the destroy callback, without making PaperTrail more complicated by adding a configuration option. I'm going to close this issue, because I feel that Ben has answered the original question. |
Hello,
my software is using Paranoia at the moment for a soft-deletes.
I have now added PaperTrail for versioning so I can track updates in certain tables.
While testing I found that deleting something will write a version data set, but only AFTER paranoia has done its update and set the "deleted" flag.
That means that code like this:
Will "restore" the data set to its deleted state, which is of course not what I want it to do.
I dug around in the code a little bit and found that changing some code in has_paper_trail.rb
seems to solve my problem.
The code I changed is the following (starting in line 97)
And I changed it to:
To solve my problem changing after_destroy to before_destroy would have been sufficient, but it seemed sensible to change update too.
I am unsure wether I created new problems with my changes or maybe destroyed functions that I am simply not using (yet), so I'd be very grateful for somebody with more experience taking a look at my problem and/or solution.
Thank you for your time, and many thanks in advance.
The text was updated successfully, but these errors were encountered: