【发布时间】:2019-05-15 02:42:54
【问题描述】:
我在 Heroku 上部署了一个应用程序 Rails。我正在使用插件 Cloudinary 和 gem Carrierwave 来上传图片。
按照 Cloudinary 文档,我可以在生产环境中成功配置上传图像,但在开发环境中,它也在上传到云端。我的问题是我想使用本地机器中的文件存储,而不是将图像上传到 Cloudinary(只需在生产中上传到 Cloudinary)。
我尝试使用storage :file if Rails.env == "development" 解决此问题,但没有成功。有什么办法解决吗?
我的上传者是:
class ImageUploader < CarrierWave::Uploader::Base
include Cloudinary::CarrierWave
include CarrierWave::MiniMagick
# storage :file if Rails.env == "development"
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :thumb do
process resize_to_fit: [50, 50]
end
version :card do
process resize_to_fit: [250, 250]
end
end
谢谢!
【问题讨论】:
标签: ruby-on-rails heroku carrierwave cloudinary uploader