为什么我会看到这样的图像...
http://i46.tinypic.com/16bn0js.png
图像存储在我的 tmp/uploads 文件夹中:
顺便说一句,我将此条件放入了 ads_uploader.rb
if Rails.env.production?
CarrierWave.configure do |config|
config.storage :fog
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def cache_dir
"#{Rails.root}/tmp/uploads"
end
end
end
if Rails.env.development?
CarrierWave.configure do |config|
config.root = Rails.root
config.storage :file
def
store_dir
"#{Rails.root}/tmp/uploads"
end
#I am not sure about this one ~SS
def cache_dir
"#{Rails.root}/tmp/uploads"
end
end
end
开发环境中上传过程成功。该文件存储在 tmp/uploads 目录中。
但是在 View 中查看它时。
ads.html.haml:
图像未显示。 (参见上面的图片网址)
请帮忙。我错过了诸如网址之类的东西吗?
最佳答案
尝试
def store_dir
"#{Rails.root}/public/uploads"
end
“/tmp”无权直接提供资源,请移至公开查看
关于ruby-on-rails - Carrierwave(开发环境)图像中的本地存储设置渲染效果不佳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12103257/