Class: AssetUploader
- Inherits:
-
CarrierWave::Uploader::Base
- Object
- CarrierWave::Uploader::Base
- AssetUploader
- Defined in:
- app/uploaders/asset_uploader.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#set_md5 ⇒ Object
Set an MD5 hash of the image.
-
#store_dir ⇒ Object
Override the directory where uploaded files will be stored.
Instance Method Details
#set_md5 ⇒ Object
Set an MD5 hash of the image
22 23 24 25 26 |
# File 'app/uploaders/asset_uploader.rb', line 22 def set_md5 if model.present? model.checksum = Digest::MD5.file(current_path).to_s end 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:
13 14 15 16 17 18 19 |
# File 'app/uploaders/asset_uploader.rb', line 13 def store_dir if model.present? "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" else "uploads/#{mounted_as}" end end |