Я добавил к существующей модели раздел версии в соответствующем загрузчике
class MyUploader < CarrierWave::Uploader::Base
include CarrierWave::MimeTypes
include CarrierWaveDirect::Uploader
# this section is new
version :preview, if: :pdf? do
process :only_first_page
process :set_png_content_type
process resize_to_limit: [1024, 1024]
process convert: :png
def full_filename(*args)
super.chomp(File.extname(super)) + '.png'
end
end
...
end
class Attachment < AR::Base
...
mount_uploader :source, MyUploader
...
end
Я ожидаю пустой предварительный просмотр соответствующей модели, но это не
attachment.source.preview #=>
=> #<MyUploader::Uploader47346938716880:0x00561fa344d810
@cache_id="1562167039-18287-6236",
@file=
#<CarrierWave::SanitizedFile:0x00561fa35c9018
@content_type="application/pdf",
@file="path_to_file",
@original_filename=nil>,
@filename="filename",
@model=
#<Attachment:0x00561fa3187ce8
...
...
Я не запускал recreate_versions!
на этом.
Почему у него непустое preview
?