Class: WineLabelUploader

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

Instance Method Summary collapse

Instance Method Details

#extension_white_listObject

Add a white list of extensions which are allowed to be uploaded. For images you might use something like this:



65
66
67
# File 'app/uploaders/wine_label_uploader.rb', line 65

def extension_white_list
  %w(jpg jpeg gif png)
end

#filenameObject



77
78
79
# File 'app/uploaders/wine_label_uploader.rb', line 77

def filename
  (super.chomp(File.extname(super)) + '.png').split(".png").first.gsub(".", "") + '.png' if original_filename
end

#move_to_cacheObject



33
34
35
# File 'app/uploaders/wine_label_uploader.rb', line 33

def move_to_cache
  false
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:



21
22
23
24
25
26
27
28
29
30
31
# File 'app/uploaders/wine_label_uploader.rb', line 21

def store_dir
  # uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}
  # /opt/razad/:wine_id/:vintage_id
  begin
    vintage = model
    wine = vintage.wine
    "wine_labels/#{wine.id}/#{vintage.id}"
  rescue
    nil
  end
end