I have an application Rails deployed on Heroku. I'm using the adds-on Cloudinary and the gem Carrierwave to upload images.
Following the Cloudinary documentation I have could configure the uploading images on Production successfully but in Development, it is also uploading to the cloud. My issue here is that I would like to use the file storage in my local machine instead of upload images to Cloudinary (just upload to Cloudinary in production).
I have tried to fix that using storage :file if Rails.env == "development" but didn't work. Any idea to solve it?
My uploader is:
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
Thanks!
I also remember not being able to handle this situation in a past project. As we were using AWS S3 we could differentiate assets from deve and prod by storing them in a different bucket, however in Cloudinary this seems to be not possible.
Maybe this setup we used for test environment might help you in your dev environment.
Place this code in
config/initializers/carrierwave.rbHope this helps you. It worked for us.