class
ActiveStorage::Attachment
- ActiveStorage::Attachment
- Marten::DB::Model
- Reference
- Object
Defined in:
active_storage/attachment.crConstant Summary
-
FIELDS_ =
{"id" => {type: "big_int", kwargs: {primary_key: true, auto: true}}, "name" => {type: "string", kwargs: {max_size: 255}}, "record_type" => {type: "string", kwargs: {max_size: 255}}, "record_id" => {type: "big_int", kwargs: ::NamedTuple.new}, "blob" => {type: "many_to_one", kwargs: {to: ActiveStorage::Blob}}, "created_at" => {type: "date_time", kwargs: {auto_now_add: true}}} of Nil => Nil
Class Method Summary
-
.attach(record_type : String, record_id : Int64, name : String, io : IO, filename : String, content_type : String | Nil = nil, service : String = "local") : ActiveStorage::Attachment
Stores
ioas a new blob and links it to(record_type, record_id, name). - .exists?(record_type : String, record_id : Int64, name : String)
-
.purge(record_type : String, record_id : Int64, name : String) : Int32
Removes every attachment matching
(record_type, record_id, name)and purges the blobs they held. -
.purge(id : Int64) : Bool
Removes the attachment with the given id and purges its blob.
-
.purge(attachment : ActiveStorage::Attachment) : Nil
Removes the given attachment and purges its blob.
Instance Method Summary
- #blob : ActiveStorage::Blob | Nil
- #blob! : ActiveStorage::Blob
- #blob=(related_object : ActiveStorage::Blob | Nil)
- #blob?
- #blob_id : Marten::DB::Field::ReferenceDBTypes | Nil
- #blob_id!
- #blob_id=(related_id : Marten::DB::Field::ReferenceDBTypes | Nil)
- #blob_id?
- #created_at : Time | Nil | Nil
- #created_at!
- #created_at=(created_at : Time | Nil | Nil)
- #created_at?
- #id : Int32 | Int64 | Nil | Nil
- #id!
- #id=(id : Int32 | Int64 | Nil | Nil)
- #id?
- #name : String | Nil | Nil
- #name!
- #name=(name : String | Nil | Nil)
- #name?
-
#purge
Synchronously deletes this attachment and purges the blob it holds.
-
#purge_later
Rails enqueues a background job here; this bridge has no job queue, so the purge runs synchronously, the same as
#purge. - #record_id : Int32 | Int64 | Nil | Nil
- #record_id!
- #record_id=(record_id : Int32 | Int64 | Nil | Nil)
- #record_id?
- #record_type : String | Nil | Nil
- #record_type!
- #record_type=(record_type : String | Nil | Nil)
- #record_type?
- #redirect_url
- #representation_url(variation : String)
Class Method Detail
Stores io as a new blob and links it to (record_type, record_id, name).
Removes every attachment matching (record_type, record_id, name) and
purges the blobs they held. Returns how many were removed.
Removes the attachment with the given id and purges its blob.
Returns false when no such attachment exists.
Removes the given attachment and purges its blob.
Instance Method Detail
Synchronously deletes this attachment and purges the blob it holds.
The attachment row goes first, because ActiveStorage::Blob#purge refuses a
blob something is still attached to. A blob another record also holds
survives, and so does its row.