class ActiveStorage::VariantRecord

Overview

Row linking a blob to one of its processed variants.

Rails writes one of these per variation when config.active_storage.track_variants is on, which is the default from load_defaults 6.1 onwards. The variant image itself is a separate blob, attached to this record under the name #image. https://github.com/rails/rails/blob/v8.1.3/activestorage/app/models/active_storage/variant_record.rb

Defined in:

active_storage/variant_record.cr

Constant Summary

FIELDS_ = {"id" => {type: "big_int", kwargs: {primary_key: true, auto: true}}, "blob" => {type: "many_to_one", kwargs: {to: ActiveStorage::Blob}}, "variation_digest" => {type: "string", kwargs: {max_size: 255}}} of Nil => Nil

Row linking a blob to one of its processed variants.

Rails writes one of these per variation when config.active_storage.track_variants is on, which is the default from load_defaults 6.1 onwards. The variant image itself is a separate blob, attached to this record under the name #image. https://github.com/rails/rails/blob/v8.1.3/activestorage/app/models/active_storage/variant_record.rb

IMAGE_ATTACHMENT_NAME = "image"

Name the variant blob is attached to this record under.

RECORD_TYPE = "ActiveStorage::VariantRecord"

Value the variant attachment rows carry in their record_type column.

Instance Method Summary

Instance Method Detail

def blob : ActiveStorage::Blob | Nil #

def blob! : ActiveStorage::Blob #

def blob=(related_object : ActiveStorage::Blob | Nil) #

def blob? #

def blob_id : Marten::DB::Field::ReferenceDBTypes | Nil #

def blob_id! #

def blob_id=(related_id : Marten::DB::Field::ReferenceDBTypes | Nil) #

def blob_id? #

def id : Int32 | Int64 | Nil | Nil #

def id! #

def id=(id : Int32 | Int64 | Nil | Nil) #

def id? #

def image : ActiveStorage::Blob | Nil #

Returns the blob holding the processed variant image, or nil when it is not attached.


def variation_digest : String | Nil | Nil #

def variation_digest! #

def variation_digest=(variation_digest : String | Nil | Nil) #

def variation_digest? #