CarrierWave.root not set when using Sinatra

238 views
Skip to first unread message

Marc

unread,
Mar 13, 2011, 9:39:06 AM3/13/11
to carrierwave
Hi all,

I'm using CarrierWave with Sinatra and Datamapper and came across a
problem where files are uploaded successfully but I get an error when
trying to access the URL property. This is the error I'm getting:

can't convert nil into String
file: url.rb location: expand_path line: 17

It's referring to the url.rb file from the CarrierWave. After some
debugging I found CarrierWave uses the following code to set the root-
property (which is needed to generate the correct URL):

CarrierWave.root = Sinatra::Application.public
(line 91, carrierwave.rb)

The problem is however, that Sinatra::Application.public is nil.

I'm still quite new to Sinatra so I'm not sure if this has to do with
the fact that I'm using the "modular approach" with Sinatra instead of
the traditional way, or whether it's something else.

Is there a way I can set the CarrierWave.root manually?

Marc

unread,
Mar 13, 2011, 10:29:23 AM3/13/11
to carrierwave
Solved it!

CarrierWave.configure do |config|
config.root = "#{Dir.pwd}/public/"
end

Pelosi

unread,
May 17, 2012, 4:09:22 PM5/17/12
to carri...@googlegroups.com
Ahh! Thank you. I had the exact same problem. 
Reply all
Reply to author
Forward
0 new messages