Skip to content

Instantly share code, notes, and snippets.

@HooFoo
Created May 7, 2019 11:33
Show Gist options
  • Select an option

  • Save HooFoo/f68862efc049b7c369faaa2441f88375 to your computer and use it in GitHub Desktop.

Select an option

Save HooFoo/f68862efc049b7c369faaa2441f88375 to your computer and use it in GitHub Desktop.
How to add cloudinary to production config only
class BaseImageUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick #
# Choose what kind of storage to use for this uploader:
if Rails.env.production?
include Cloudinary::CarrierWave
else
storage :file
end
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def extension_whitelist
%w(jpg jpeg gif png)
end
end
gem 'active_admin_editor', github: 'boontdustie/active_admin_editor'
gem 'carrierwave'
group :development, :test do
gem 'rmagick'
gem 'mini_magick'
end
group :production do
gem 'cloudinary'
end
class PhotoUploader < BaseImageUploader
process :resize_to_fit => [1500,1500]
version :thumb do
process :resize_to_fit => [100,100]
end
version :miniature do
process :resize_to_fill => [200, 200]
end
version :preview do
process :resize_to_fill => [400, 400]
end
version :base do
process :resize_to_fit => [500,500]
end
def default_url(*args)
"/images/fallback/" + [version_name, "default.png"].compact.join('_')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment