Created
August 13, 2012 12:18
-
-
Save donovan-duplessis/3340117 to your computer and use it in GitHub Desktop.
Save extra file metadata (carrierwave uploader)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def save_file_details(file) | |
model.document_original = file.original_filename if file.respond_to?(:original_filename) | |
fields = {:document_type => file.content_type, :document_size => file.size} | |
fields.each do |field, value| | |
if model.has_attribute? field | |
model.send("#{field}=", value) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment