使用 Rails 3.2.13 和 Carrierwave 0.9.0,我注意到我的图像在上传时都被旋转了,所以我想自动调整它们的方向。这是上传者:
class PhotoUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
process :auto_orient
storage :fog
def auto_orient
manipulate! do |img|
img.auto_orient
img
end
end
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
添加工艺线后,图像将不再保存到数据库中。如果我注释掉那一行,它们会保存得很好。我使用的表单允许一次上传多张照片,并且photos_attributes 嵌套在相册资源下,因为它们是一起创建的。这是照片模型:
class Photo < ActiveRecord::Base
attr_accessible :photo ...
mount_uploader :photo, PhotoUploader
belongs_to :album
end
我怎样才能得到这个工作?