使用 Cloud 66 将 rails 应用程序部署到 digitalocean.com。一切正常,除了尝试上传图片时出现一些权限错误。
Errno::EACCES (Permission denied - /var/deploy/anabol/web_head/releases/20130608104347/public/uploads/tmp):
image_uploader.rb
class ImageUploader < CarrierWave::Uploader::Base
...
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
...
end
这里有描述,如何解决问题: https ://www.cloud66.com/help/permission_denied_errors
我将 store_dir 路径更改为:
def store_dir
"#{Rails.root}/tmp/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
但这没有帮助。我仍然收到此错误:
» 13:49:25.696 Errno::EACCES (Permission denied - /var/deploy/anabol/web_head/releases/20130608114659/public/uploads/tmp):
我错过了什么吗?
编辑:
上传适用于 image_uploader.rb 中的这一部分:
def cache_dir
# should return path to cache dir
Rails.root.join 'tmp/uploads/cache'
end
def store_dir
"#{Rails.root}/tmp/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
但现在我得到:
ActionController::RoutingError (No route matches [GET] "/var/deploy/anabol/web_head/releases/20130608164223/tmp/uploads/profile/image/3/thumb_Screenshot_from_2013-06-05_17_27_54.png"):
在视图中,仅显示图像路径。