Class: Raport::FileUploader
- Inherits:
-
CarrierWave::Uploader::Base
- Object
- CarrierWave::Uploader::Base
- Raport::FileUploader
- Includes:
- CarrierWave::MiniMagick
- Defined in:
- app/uploaders/raport/file_uploader.rb
Instance Method Summary collapse
-
#filename ⇒ Object
process :set_file_size.
- #set_content_type ⇒ Object
- #store_dir ⇒ Object
Instance Method Details
#filename ⇒ Object
process :set_file_size
def set_file_size
model.file_size = file.size
end
30 31 32 |
# File 'app/uploaders/raport/file_uploader.rb', line 30 def filename model.respond_to?(:filename) ? model.filename : super end |
#set_content_type ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'app/uploaders/raport/file_uploader.rb', line 14 def set_content_type new_content_type = 'binary/octet-stream' if file.respond_to?(:content_type=) file.content_type = new_content_type else file.instance_variable_set(:@content_type, new_content_type) end end |
#store_dir ⇒ Object
8 9 10 |
# File 'app/uploaders/raport/file_uploader.rb', line 8 def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end |