文件上传pdf问题
File upload pdf issue
我正在使用 carrierwave、minimagick 和 Rails 4.
我有一个 FileUploader,如下所示:
class FileUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
version :thumb, if: :image? do
process :resize_to_limit => [50, 50]
end
version :thumb, unless: :image? do
process :cover
process :resize_to_fill => [50, 50, Magick::NorthGravity]
process :convert => 'png'
end
protected
def image?(new_file)
new_file.content_type.start_with? 'image'
end
def cover
manipulate! do |frame, index|
frame if index.zero?
end
end
end
如果上传了 pdf,我正在尝试创建第一页的缩略图 png 版本。如果上传了图片,我会调整大小并保存它的缩略图版本。
我现在收到错误:NameError (uninitialized constant FileUploader::Magick)
,虽然当我用 unless
移除块时它起作用了
Magick::NorthGravity
常量是 rmagick
gem 的一部分(参见 here),而不是 mini_magick
.
的一部分
我正在使用 carrierwave、minimagick 和 Rails 4.
我有一个 FileUploader,如下所示:
class FileUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
version :thumb, if: :image? do
process :resize_to_limit => [50, 50]
end
version :thumb, unless: :image? do
process :cover
process :resize_to_fill => [50, 50, Magick::NorthGravity]
process :convert => 'png'
end
protected
def image?(new_file)
new_file.content_type.start_with? 'image'
end
def cover
manipulate! do |frame, index|
frame if index.zero?
end
end
end
如果上传了 pdf,我正在尝试创建第一页的缩略图 png 版本。如果上传了图片,我会调整大小并保存它的缩略图版本。
我现在收到错误:NameError (uninitialized constant FileUploader::Magick)
,虽然当我用 unless
Magick::NorthGravity
常量是 rmagick
gem 的一部分(参见 here),而不是 mini_magick
.