Skip to content

How to: Dynamically set storage type

k33l0r edited this page Oct 9, 2012 · 2 revisions

You can set the storage type dynamically by passing in a class method of your uploader to the storage method.

Example:

class AvatarUploader < CarrierWave::Uploader::Base
  def self.set_storage
    if Configuration.use_cloudfiles?
      :fog
    else
      :file
    end
  end

  storage set_storage
end
Clone this wiki locally