Class: RedditorUploader

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

Instance Method Summary collapse

Instance Method Details

#is_image?(picture) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/uploaders/redditor_uploader.rb', line 53

def is_image? picture
  model.imageable_type == "Redditor::Page"
end

#is_slider?(picture) ⇒ Boolean

Для того чтобы можно было использовать эти методы ввиде условий необходимо, чтобы изображение сохранялось через update_attributes вместо save

Returns:

  • (Boolean)


49
50
51
# File 'app/uploaders/redditor_uploader.rb', line 49

def is_slider? picture
  model.imageable_type == "Redditor::SliderBlock"
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:



15
16
17
# File 'app/uploaders/redditor_uploader.rb', line 15

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