Skip to content

Saving Content Type

Semenyk Dmitriy edited this page May 22, 2013 · 1 revision

If you need to save content type in your model, you could use this:

require 'carrierwave/processing/mime_types'

class MyUploader < CarrierWave::Uploader::Base
  include CarrierWave::MimeTypes

  process :save_content_type_in_model

  def save_content_type_in_model
    # replace `file_content_type` with your field name
    model.file_content_type = file.content_type if file.content_type
  end
end
Clone this wiki locally