Search code examples
ruby-on-railsrails-activestorage

Is it possible to prevent ActiveStorage from deleting file on service storage?


I'm using ActiveStorage to handle attachments in my rails app. When updating the attachment of a model, it seems to enqueue a purge job and it deletes the previous attached file on the remote storage service (S3 here).

I don't want the files in my S3 bucket to be systematically deleted (even if no record is attached to it in my database), is it possible to prevent these purge job to be enqueued?


Solution

  • After reading again the documentation:

    If the :dependent option isn't set, the attachment will be purged (i.e. destroyed) whenever the record is destroyed.