класс ActiveStorage::VariantWithRecord
Вариант Active Storage с записями
Подобно ActiveStorage::Variant, но сохраняет детали о варианте в базе данных как ActiveStorage::VariantRecord. Используется только если ActiveStorage.track_variants включено.
Атрибуты
blob[R]
variation[R]
Публичные методы класса
# File activestorage/app/models/active_storage/variant_with_record.rb, line 12 def initialize(blob, variation) @blob, @variation = blob, ActiveStorage::Variation.wrap(variation) end
Публичные методы экземпляра
# File activestorage/app/models/active_storage/variant_with_record.rb, line 30 def destroy record&.destroy end
Удаляет запись и файл из сервиса.
# File activestorage/app/models/active_storage/variant_with_record.rb, line 25
def filename
ActiveStorage::Filename.new "#{blob.filename.base}.#{variation.format.downcase}"
end # File activestorage/app/models/active_storage/variant_with_record.rb, line 21 def image record&.image end
# File activestorage/app/models/active_storage/variant_with_record.rb, line 16 def processed process unless processed? self end
© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.