Open BassamAziz opened 5 years ago
@BassamAziz absolutely possible, you have to read the ActiveStorage model code here: https://github.com/rails/rails/tree/master/activestorage/app/models/active_storage
Basically, it's something like:
ActiveStorage::Attachment.audited
This works, if I put that code in config/initializers - is that a correct way to approach it?
@garyfoster yes, I guess this is the best practice doing that. Created something like audited.rb
and put it into the initializers and add this code. I suggest to use shrine
for the attachments, as it's more modular and don't have many issues like activestorage has.
This has been working great in an initializer: (and yes, active storage has been a joke)
Rails.configuration.to_prepare do ActiveStorage::Attachment.audited associated_with: :record end
Hi @garyfoster ... also trying to keep track of changes to file attachments with audited gem. I am using
Rails.configuration.to_prepare do ActiveStorage::Attachment.audited associated_with: :record end
Rails.configuration.to_prepare do ActiveStorage::Blob.audited end
in initializer. Current situation is that only creation of ActiveStorage::Attachment objects are getting audited (no destroy) ... ?
So in general what's the right/clean way to get associated audits for file attachments for a given model?
THX a lot! mscdit
Is there a way to audit file changes (with active storage). so that old files will still be associated with old versions, and new versions will refer to the new files. thank you all.