class ActiveStorage::Attachment
def variant(transformations)
Raises an +ArgumentError+ if +transformations+ is a +Symbol+ which is an
See ActiveStorage::Blob::Representable#variant for more information.
instance for the attachment with the set of +transformations+ provided.
Returns an ActiveStorage::Variant or ActiveStorage::VariantWithRecord
def variant(transformations) case transformations when Symbol variant_name = transformations transformations = variants.fetch(variant_name) do record_model_name = record.to_model.model_name.name raise ArgumentError, "Cannot find variant :#{variant_name} for #{record_model_name}##{name}" end end blob.variant(transformations) end