Class: ImageUploader

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

Instance Method Summary collapse

Instance Method Details

#cropObject



28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/uploaders/image_uploader.rb', line 28

def crop
  if model.crop_x.present?
    resize_to_limit(540, 540)
    manipulate! do |img|
      x = model.crop_x.to_i
      y = model.crop_y.to_i
      w = model.crop_w.to_i
      h = model.crop_h.to_i
      img.crop!(x, y, w, h)
    end
  end
end

#store_dirObject

Override the directory where uploaded files will be stored. This is a sensible default for uploaders that are meant to be mounted:



9
10
11
# File 'app/uploaders/image_uploader.rb', line 9

def store_dir
  "public/uploads/#{model.class.to_s.underscore}/#{model.id}"
end