Skip to Content Skip to Search

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.

Methods
D
F
I
N
P

Attributes

[R] blob
[R] variation

Class Public methods

new(blob, variation)

# File activestorage/app/models/active_storage/variant_with_record.rb, line 14
def initialize(blob, variation)
  @blob, @variation = blob, ActiveStorage::Variation.wrap(variation)
end

Instance Public methods

destroy()

Destroys record and deletes file from service.

# File activestorage/app/models/active_storage/variant_with_record.rb, line 32
def destroy
  record&.destroy
end

filename()

# File activestorage/app/models/active_storage/variant_with_record.rb, line 27
def filename
  ActiveStorage::Filename.new "#{blob.filename.base}.#{variation.format.downcase}"
end

image()

# File activestorage/app/models/active_storage/variant_with_record.rb, line 23
def image
  record&.image
end

processed()

# File activestorage/app/models/active_storage/variant_with_record.rb, line 18
def processed
  process unless processed?
  self
end