Class: ActiveStorage::Attachment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActiveStorage::Attachment
- Defined in:
- app/models/active_storage/attachment.rb
Overview
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).
Instance Method Summary collapse
-
#purge ⇒ Object
Synchronously purges the blob (deletes it from the configured service) and destroys the attachment.
-
#purge_later ⇒ Object
Destroys the attachment and asynchronously purges the blob (deletes it from the configured service).
Instance Method Details
#purge ⇒ Object
Synchronously purges the blob (deletes it from the configured service) and destroys the attachment.
20 21 22 23 |
# File 'app/models/active_storage/attachment.rb', line 20 def purge destroy blob.purge end |
#purge_later ⇒ Object
Destroys the attachment and asynchronously purges the blob (deletes it from the configured service).
26 27 28 29 |
# File 'app/models/active_storage/attachment.rb', line 26 def purge_later destroy blob.purge_later end |