Currently, I've implemented a Rails Data Auditing app using PaperTrail.
I've added a new version for every create, update and destroy actions.
The thing is that, I have an after_create callback in my model in which I want the PaperTrail to ignore it.
For now, when I create a new record, there are two versions are created. One is of the create event, and other one is of the update event of my callback.
What I want is to just one version to be created here, a version of the create event.
To be specific, my callback is just to add a slug, an alias is, to my record in which I do not want to show such this change to the user.
I wonder if there is a way to do so.
Any suggestions are appreciated.
Thanks,
without_versioning was removed in v10, as mentionned here.
Use instead :
PaperTrail.request(enabled: false) do
# no versions created
end
Or for specific model only :
PaperTrail.request.disable_model(Banana)
# changes to Banana model do not create versions,
# but eg. changes to Kiwi model do.
PaperTrail.request.enable_model(Banana)
I think you can make use of without_versioning, which
Executes the given method or block without creating a new version
user.without_versioning { |obj| obj.update_attributes(attribute: 'new_value') }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With