uninitialized constant CarrierWave::Storage::Fog

2,687 views
Skip to first unread message

gboruk

unread,
Jul 29, 2011, 6:33:51 PM7/29/11
to carrierwave
I followed the direction on the README and when I try to use fog for
s3 storage, I get the following:

/Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/carrierwave-0.5.6/lib/
carrierwave/uploader/configuration.rb:89:in `eval': uninitialized
constant CarrierWave::Storage::Fog (NameError)
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/carrierwave-0.5.6/
lib/carrierwave/uploader/configuration.rb:89:in `eval'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/carrierwave-0.5.6/
lib/carrierwave/uploader/configuration.rb:89:in `storage'
from /Users/gboruk/Documents/Development/stories/app/uploaders/
image_uploader.rb:11:in `<class:ImageUploader>'
from /Users/gboruk/Documents/Development/stories/app/uploaders/
image_uploader.rb:3:in `<top (required)>'
from /Users/gboruk/Documents/Development/stories/app/models/page.rb:
11:in `<class:Page>'
from /Users/gboruk/Documents/Development/stories/app/models/page.rb:
2:in `<top (required)>'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/mongoid-2.0.2/lib/
rails/mongoid.rb:55:in `load_model'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/mongoid-2.0.2/lib/
rails/mongoid.rb:18:in `block (2 levels) in load_models'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/mongoid-2.0.2/lib/
rails/mongoid.rb:17:in `each'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/mongoid-2.0.2/lib/
rails/mongoid.rb:17:in `block in load_models'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/paths.rb:102:in `block in each'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/paths.rb:102:in `each'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/paths.rb:102:in `each'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/mongoid-2.0.2/lib/
rails/mongoid.rb:16:in `load_models'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/mongoid-2.0.2/lib/
mongoid/railtie.rb:86:in `block (2 levels) in <class:Railtie>'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/
lib/active_support/callbacks.rb:420:in `_run_prepare_callbacks'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.7/
lib/action_dispatch/middleware/callbacks.rb:40:in `initialize'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.7/
lib/action_dispatch/middleware/stack.rb:33:in `new'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.7/
lib/action_dispatch/middleware/stack.rb:33:in `build'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.7/
lib/action_dispatch/middleware/stack.rb:79:in `block in build'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.7/
lib/action_dispatch/middleware/stack.rb:79:in `each'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.7/
lib/action_dispatch/middleware/stack.rb:79:in `inject'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.7/
lib/action_dispatch/middleware/stack.rb:79:in `build'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/application.rb:162:in `app'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/application/finisher.rb:35:in `block in <module:Finisher>'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/initializable.rb:25:in `instance_exec'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/initializable.rb:25:in `run'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/initializable.rb:50:in `block in run_initializers'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/initializable.rb:49:in `each'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/initializable.rb:49:in `run_initializers'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/application.rb:134:in `initialize!'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/application.rb:77:in `method_missing'
from /Users/gboruk/Documents/Development/stories/config/
environment.rb:5:in `<top (required)>'
from /Users/gboruk/Documents/Development/stories/config.ru:3:in
`block in <main>'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/
builder.rb:46:in `instance_eval'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/
builder.rb:46:in `initialize'
from /Users/gboruk/Documents/Development/stories/config.ru:1:in `new'
from /Users/gboruk/Documents/Development/stories/config.ru:1:in
`<main>'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/
builder.rb:35:in `eval'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/
builder.rb:35:in `parse_file'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/
server.rb:162:in `app'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/
server.rb:253:in `wrapped_app'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/
server.rb:204:in `start'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/commands/server.rb:65:in `start'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/commands.rb:30:in `block in <top (required)>'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/commands.rb:27:in `tap'
from /Users/gboruk/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/
rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'



If I use :file, it works fine and the upload works. if i use :s3 for
storage, i get a different error saying that my bucket name is invalid
and that it's nil.


Any help would be much appreciated

Trevor Turk

unread,
Aug 1, 2011, 2:49:39 PM8/1/11
to carri...@googlegroups.com
I'd suggest checking out the README in detail. You want to use the "fog" storage module. Make sure you're using the latest version of the gem. 

gboruk

unread,
Aug 1, 2011, 3:16:22 PM8/1/11
to carri...@googlegroups.com
Myself & a co-worker both looked at the README in detail and made sure our reflects the instructions.  I'm using carrierwave 0.5.6 and fog 0.10.0

Below is my lib/carrierwave/storage/fog.rb file:

CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider               => 'AWS',       # required
    :aws_access_key_id      => '<My access key>',       # required
    :aws_secret_access_key  => '<my secret access key>',       # required
  }
  config.fog_directory  = '<my bucket name>'                    
  config.fog_host       = '<my s3 host name>'            # optional, defaults to nil

end

and i have storage :fog in my uploader class.  


Note, I did get it working using the s3 module, but I'd prefer to stick to what you guys recommend and use fog, so i'm really eager to get this to work.  I may be missing something, but i think i'm following the README to the t.

Trevor Turk

unread,
Aug 5, 2011, 2:13:48 PM8/5/11
to carri...@googlegroups.com
I'm sorry, but you must be doing something wrong... I'm just not sure what. Perhaps you could start with a fresh Rails app from scratch and see if that helps identify the problem. If you post an app to github and link to it here, someone might be able to help troubleshoot. 

Eliman

unread,
Sep 21, 2011, 11:05:33 AM9/21/11
to carrierwave
It happened to me also, its a silly mistake.

The fog credentials should be in an initializer, not in lib/
carrierwave/storage/fog.rb.

As the README clearly states.

Eliman

unread,
Sep 21, 2011, 11:00:34 AM9/21/11
to carrierwave
It happened to me also. It's a silly mistake.

The README clearly states that the fog configuration should be in an
initializer, not in lib/carrierwave/storage/fog.rb

If you add the credentials in a file located in lib/carrierwave/
storage/fog.rb inside your proyect, you will get that error.

kibaekr

unread,
Apr 28, 2012, 5:37:59 AM4/28/12
to carri...@googlegroups.com
What do you mean initializer? Can you give me an example file/folder of where we would put that code in? The README documentation seems like it is directing us to create the file inside the lib/carrierwave/storage/fog.rb. Are you saying we should instead create a file called fob.rb inside config/initializers? or does it have to be config/initializers/lib/carriierwave/storage/fog.rb?
Reply all
Reply to author
Forward
0 new messages