Skip to content

How to: Dynamically set storage type

rrouse edited this page Aug 30, 2011 · 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