Skip to content

Instantly share code, notes, and snippets.

@donovan-duplessis
Created August 13, 2012 12:18
Show Gist options
  • Save donovan-duplessis/3340117 to your computer and use it in GitHub Desktop.
Save donovan-duplessis/3340117 to your computer and use it in GitHub Desktop.
Save extra file metadata (carrierwave uploader)
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