class ActiveStorage::VariantWithRecord
Вариант Active Storage с записью
Как ActiveStorage::Variant, но сохраняет сведения о варианте в базе данных как ActiveStorage::VariantRecord. Используется только при включённом ActiveStorage.track_variants.
Атрибуты
Публичные методы класса
# File activestorage/app/models/active_storage/variant_with_record.rb, line 14 def initialize(blob, variation) @blob, @variation = blob, ActiveStorage::Variation.wrap(variation) end
Публичные методы экземпляра
# File activestorage/app/models/active_storage/variant_with_record.rb, line 32 def destroy record&.destroy end
Удаляет запись и файл из хранилища.
# 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.