class ActiveStorage::Attachment
Attachments associate records with blobs. Usually that's a one record-many blobs relationship, but it is possible to associate many different records with the same blob. If you're doing that, you'll want to declare with has_one/many_attached :thingy, dependent: false
, so that destroying any one record won't destroy the blob as well. (Then you'll need to do your own garbage collecting, though).
Public Instance Methods
purge()
click to toggle source
Synchronously purges the blob (deletes it from the configured service) and destroys the attachment.
# File activestorage/app/models/active_storage/attachment.rb, line 18 def purge blob.purge destroy end
purge_later()
click to toggle source
Destroys the attachment and asynchronously purges the blob (deletes it from the configured service).
# File activestorage/app/models/active_storage/attachment.rb, line 24 def purge_later blob.purge_later destroy end