Class: PictureFileUploader
- Inherits:
-
CarrierWave::Uploader::Base
- Object
- CarrierWave::Uploader::Base
- PictureFileUploader
- Includes:
- CarrierWave::RMagick
- Defined in:
- app/uploaders/picture_file_uploader.rb
Instance Method Summary collapse
-
#extension_white_list ⇒ Object
Add a white list of extensions which are allowed to be uploaded.
- #filename ⇒ Object
- #move_to_cache ⇒ Object
-
#store_dir ⇒ Object
Override the directory where uploaded files will be stored.
Instance Method Details
#extension_white_list ⇒ Object
Add a white list of extensions which are allowed to be uploaded. For images you might use something like this:
59 60 61 |
# File 'app/uploaders/picture_file_uploader.rb', line 59 def extension_white_list %w(jpg jpeg gif png) end |
#filename ⇒ Object
71 72 73 |
# File 'app/uploaders/picture_file_uploader.rb', line 71 def filename (super.chomp(File.extname(super)) + '.png').split(".png").first.gsub(".", "") + '.png' if original_filename end |
#move_to_cache ⇒ Object
30 31 32 |
# File 'app/uploaders/picture_file_uploader.rb', line 30 def move_to_cache false end |
#store_dir ⇒ Object
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 |
# File 'app/uploaders/picture_file_uploader.rb', line 21 def store_dir # uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id} # /opt/razad/:interpro_name-:interpro_id/:producer_name-:producer_id/:wine_name-:wine_id/:vintage_title-:vintage_id picture = model user = picture.user "pictures/#{user.id}" end |