Class: PhotoUploader
- Inherits:
-
CarrierWave::Uploader::Base
- Object
- CarrierWave::Uploader::Base
- PhotoUploader
- Includes:
- CarrierWave::RMagick
- Defined in:
- app/uploaders/photo_uploader.rb
Instance Method Summary collapse
-
#cache_dir ⇒ Object
got this from stackoverflow.com/questions/9561641/carrierwave-temp-directory-set-to-uploads-tmp-folder without this all tmp files would go to /public/uploads/tmp which is not cool at all.
-
#extension_white_list ⇒ Object
Add a white list of extensions which are allowed to be uploaded.
-
#store_dir ⇒ Object
Override the directory where uploaded files will be stored.
Instance Method Details
#cache_dir ⇒ Object
got this from stackoverflow.com/questions/9561641/carrierwave-temp-directory-set-to-uploads-tmp-folder without this all tmp files would go to /public/uploads/tmp which is not cool at all.
63 64 65 66 |
# File 'app/uploaders/photo_uploader.rb', line 63 def cache_dir # should return path to cache dir Rails.root.join 'tmp/uploads' end |
#extension_white_list ⇒ Object
Add a white list of extensions which are allowed to be uploaded. For photos you might use something like this:
51 52 53 |
# File 'app/uploaders/photo_uploader.rb', line 51 def extension_white_list %w(jpg jpeg png) 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:
19 20 21 22 |
# File 'app/uploaders/photo_uploader.rb', line 19 def store_dir # "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" --- that was the suggested one "system/photos/#{model.class.to_s.underscore}/#{model.id}" end |