-
Notifications
You must be signed in to change notification settings - Fork 31
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
Causes PaperTrail "destroy" versions to not be found #37
Comments
Actually, it looks like the hard-coded use of So I'm not sure why I didn't notice this before... |
We have an app that needs to be absolutely accurate in describing past audit history, and while we have no intent to use store_base_sti_class, this kind of issue was a primary motivating factor when we had put together PR#1108. While that code works out great for our code base, it compromised the ability to use .joins() along with the :versions association, so certainly many other projects were adversely affected. As well, some projects rely on having After working through various scenarios, the cleanest option we had finally arrived upon for The most unique part, which left a bad taste in the mouth of the maintainers of the PaperTrail gem, is this part which directly attaches a method to the Reflection object for :versions which attach to a subclassed model. Our team is in the process of determining what final approach we might end up with to have our stored audit history be absolutely precise, and the secondary goal to reify objects across I realise this might not solve the issue here, but perhaps it gives a little more food for thought in the quest of having |
Thanks for chiming in, @lorint. I've been watching your PR(s) with great interest to see how it all shakes out. I even tried out your branch for a while. (Ended up running into a really obscure AR behavior that I don't have time to describe (I hope it was just a dream) so switched over to Those sound like great goals that you have, goals which many paper_trail users probably share. Keep up the good work! (By the way, my name is Tyler Rick, not Rick Tyler as many people seem to like to transpose it to be. :) ) |
I'm pinging this issue as paper_trails has evolved. Is this still an issue ? |
I ran into a problem while trying out this branch of paper_trail (and a couple related ones): paper-trail-gem/paper_trail#1143. (It's not in master yet, but it could end up there soon)
When using
store_base_sti_class
, you can't find PaperTrail "destroy" versions through theversions
association becausestore_base_sti_class
causes thehas_many :versions
association to look for version recordswhere(item_type: subclass)
instead of the Rails default ofwhere(item_type: base_class)
.Non-destroy versions still work as expected with
store_base_sti_class
, since those get created through a standardhas_many
, which meansitem_type
gets set to the subclass due tostore_base_sti_class
:The problem is that when paper_trail creates "destroy" versions,,it doesn't go through the
versions
association — it hard-codes it to always store thebase_class
initem_type
— such that the ActiveRecord hacks thatstore_base_sti_class
provides have no effect.So if you do this:
you'll find that the destroy event is not there!
Here's the code used for creating destroy versions:
You can see it doesn't go through
versions_assoc
like it does for update events. It just callsVersion.create
directly.The text was updated successfully, but these errors were encountered: