Class: AvatarUploader

Inherits:
CarrierWave::Uploader::Base
  • Object
show all
Includes:
CarrierWave::MiniMagick
Defined in:
app/uploaders/avatar_uploader.rb

Instance Method Summary collapse

Instance Method Details

#cache_dirObject



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_urlObject



13
14
15
# File 'app/uploaders/avatar_uploader.rb', line 13

def default_url
  "/images/avatar_missing.png"
end

#extension_white_listObject



27
28
29
# File 'app/uploaders/avatar_uploader.rb', line 27

def extension_white_list
  %w(jpg jpeg gif png)
end

#store_dirObject

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