Class: AvatarUploader
- Inherits:
-
CarrierWave::Uploader::Base
- Object
- CarrierWave::Uploader::Base
- AvatarUploader
- Includes:
- CarrierWave::MiniMagick
- Defined in:
- app/uploaders/avatar_uploader.rb
Instance Method Summary collapse
- #cache_dir ⇒ Object
- #crop_and_resize(width, height) ⇒ Object
- #default_url ⇒ Object
- #extension_white_list ⇒ Object
-
#store_dir ⇒ Object
storage :fog unless Rails.env.test? or Rails.env.cucumber?.
Instance Method Details
#cache_dir ⇒ Object
23 24 25 |
# File 'app/uploaders/avatar_uploader.rb', line 23 def cache_dir "#{Rails.root}/tmp/uploads" end |
#crop_and_resize(width, height) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'app/uploaders/avatar_uploader.rb', line 31 def crop_and_resize(width, height) return if !model.cropping? manipulate! do |img| img.crop model.crop_string img.resize "#{width}x#{height}" img = yield(img) if block_given? img end end |
#default_url ⇒ Object
13 14 15 |
# File 'app/uploaders/avatar_uploader.rb', line 13 def default_url "/images/avatar_missing.png" end |
#extension_white_list ⇒ Object
27 28 29 |
# File 'app/uploaders/avatar_uploader.rb', line 27 def extension_white_list %w(jpg jpeg gif png) end |
#store_dir ⇒ Object
storage :fog unless Rails.env.test? or Rails.env.cucumber?
9 10 11 |
# File 'app/uploaders/avatar_uploader.rb', line 9 def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end |