I have a User model, which has one image.
class User < ApplicationRecord
has_paper_trail
has_one_attached :image
end
I decided to paper_trail gem because I need versioning for User attributes. However, I noticed that I don't know how to get versioning information for image.
PaperTrail::Version.where(item_type: "User").first.object
=> "---\nemail:XXXX\n'\ncreated_at: 2021-10-28 13:06:15.206202000\nupdated_at: 2021-10-28 13:06:19.789124000\n"
Does anyone else know how to get previous version of ActiveStorage? I'm using paper_trail gem, so it's the best if paper_trail can do it.
Ok, I'm a little late to the party, but I have found a need for version tracking on my ActiveStorage models. Here's what worked for me:
/config/initializers called active_storage.rb/config/initializers/active_storage.rb file, add the following code:Rails.application.config.to_prepare do
ActiveStorage::Record.has_paper_trail
end
You should now see version tracking for all subclasses of ActiveStorage::Record.
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