我有一个名为 Book 的模型,它有一个 cover_image。
mount_uploader :cover_image, BookPixUploader
上传者声明如下:
class BookPixUploader < CarrierWave::Uploader::Base
# Include RMagick or ImageScience support:
include CarrierWave::RMagick
CarrierWave::Uploader::ExtensionWhitelist
# include CarrierWave::MiniMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
#storage :file
storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"system/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
....
我正在尝试保存一本新书:
newbook = book.dup
newbook.save
但它不会将新图像上传到亚马逊 S3。
我试过了:
newbook = book.dup
newbook.cover_image = book.cover_image
newbook.save
有任何想法吗?