【发布时间】:2014-10-24 02:27:21
【问题描述】:
这是我的上传者:
class PhotoUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
process :resize_to_fit => [nil, 600]
version :thumb do
process :resize_to_fill => [150,150]
end
# Choose what kind of storage to use for this uploader:
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def cache_dir
"#{Rails.root}/tmp/uploads"
end
def extension_white_list
%w(jpg jpeg gif png)
end
def filename
if original_filename
@name ||= Digest::MD5.hexdigest(current_path)
"#{@name}.#{file.extension}"
end
end
end
在production.rb中,我设置了config.serve_static_assets = false。
然后我使用 Capistrano 在生产服务器(Nginx + Passenger)上部署了这个项目。当我上传图片时,它会在/home/deploy/Gallary/current/public/uploads/picture/photo/目录下生成2份,如下图所示:
我可以通过浏览器访问第一个(因为这个是Carrierwave生成的默认文件),而第二个(由version :thumb生成)抛出一个异常,如下所示:
ActionController::RoutingError (No route matches [GET] "/uploads/picture/photo/49/thumb_6d9596c7449d3714eadb74b9c71beec2.jpg")
实际上这个文件thumb_6d9596c7449d3714eadb74b9c71beec2.jpg确实存在于那里的dic中。
那么,怎么了?我该怎么办?
【问题讨论】:
标签: ruby-on-rails nginx carrierwave production