Skip to content

How to: Make CarrierWave work with Padrino

Jessica Ete edited this page Jul 16, 2016 · 5 revisions

There are a few interesting things about using CarrierWave with Padrino which you'll need to know in order to get them to work together seamlessly.

First, you can require CarrierWave like this in your Padrino application's gem file (please note that you will need to specify which ORM you intend to use. The example below uses Active Record):

gem 'carrierwave', :require => ['carrierwave', 'carrierwave/orm/activerecord']

If you want to require a specific ORM to work with CarrierWave, you can put that in the Gemfile too:

gem 'carrierwave', :require => 'carrierwave'
gem 'carrierwave-sequel', :require => 'carrierwave/sequel'

Your uploaders will be automatically required if you put them in the lib/ folder.

In versions of CarrierWave prior to 0.5.8, CarrierWave.root never gets set during the Padrino boot sequence, so you may see errors like this when using CarrierWave with Padrino:

TypeError: can't convert nil into String

To avoid this, put the following code into your config/boot.rb file (or app/app.rb file):

  CarrierWave.root = File.join(Padrino.root, "public")

This has been fixed in trunk, but it's worth knowing about if you're running across this in an earlier version.

Clone this wiki locally