Module: Milton::Uploading::InstanceMethods
- Defined in:
- lib/milton/uploading.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#file=(file) ⇒ Object
Set file=<uploaded file> on your model to handle an uploaded file.
Class Method Details
.included(base) ⇒ Object
27 28 29 30 |
# File 'lib/milton/uploading.rb', line 27 def self.included(base) # Rails 2.1 fix for callbacks base.define_callbacks *[:before_file_saved, :after_file_saved] if base.respond_to?(:define_callbacks) end |
Instance Method Details
#file=(file) ⇒ Object
Set file=<uploaded file> on your model to handle an uploaded file.
33 34 35 36 37 38 39 |
# File 'lib/milton/uploading.rb', line 33 def file=(file) return nil if file.nil? || file.size == 0 @upload = Upload.new(file, self.class.) self.filename = @upload.filename self.size = @upload.size if respond_to?(:size=) self.content_type = Milton::File.mime_type?(@upload) if respond_to?(:content_type=) end |