class ActiveStorage::VariantWithRecord
Active Storage Variant With Record
Like an ActiveStorage::Variant, but keeps detail about the variant in the database as an ActiveStorage::VariantRecord. This is only used if ActiveStorage.track_variants is enabled.
Attributes
blob[R]
variation[R]
Public Class Methods
# File activestorage/app/models/active_storage/variant_with_record.rb, line 14 def initialize(blob, variation) @blob, @variation = blob, ActiveStorage::Variation.wrap(variation) end
Public Instance Methods
# File activestorage/app/models/active_storage/variant_with_record.rb, line 32 def destroy record&.destroy end
Destroys record and deletes file from service.
# File activestorage/app/models/active_storage/variant_with_record.rb, line 27
def filename
ActiveStorage::Filename.new "#{blob.filename.base}.#{variation.format.downcase}"
end # File activestorage/app/models/active_storage/variant_with_record.rb, line 23 def image record&.image end
# File activestorage/app/models/active_storage/variant_with_record.rb, line 18 def processed process unless processed? self end
© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.