Created
May 7, 2019 11:33
-
-
Save HooFoo/f68862efc049b7c369faaa2441f88375 to your computer and use it in GitHub Desktop.
How to add cloudinary to production config only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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