Carrierwave Gem - Heroku - Fog Gem configuration - Giving name error
Asked Answered
M

1

6

I am a little lost with Heroku and Carrierwave Gem. I have read the WIKI, Read me and searched the net and i admit, i need help. Everything well on local but Heroku crushes the application.

///ERROR MESSAGE FROM HEROKU LOGS

2012-01-03T17:33:26+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/carrierwave-0.5.8/lib/carrierwave/uploader/configuration.rb:91:in `eval': uninitialized constant CarrierWave::Storage::Fog (NameError

///GEM FILE

gem "fog"
gem 'carrierwave'

/app/uploaders/avatar_uploader.rb

storage :fog

/config/initializers/carrierwave.rb

CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider               => 'AWS',    
    :aws_access_key_id      => 'XXXX',    
    :aws_secret_access_key  => 'XXXX',   
    :region                 => 'eu-west-1'  # optional, defaults to 'us-east-1'
  }
  config.fog_directory  = 'site_images'  # required
  config.fog_public     = true     # optional, defaults to true
  config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}  # optional, defaults to {}
end

When i change the storage to file not fog, then i do not get errors. Are there any other fog settings i am skipping or missing. Any help greatly appreciated. Do i need to create a separate document with fog settings?

Mailable answered 3/1, 2012 at 18:19 Comment(3)
You haven't missed anything - but just to check the obvious, you have bundled and committed the lock file and pushed that to heroku? I'm running the same version of Carrierwave as you on Heroku with Fog and it's fine so it's something specific for your case I'm afraid. You don't happen to have any fog credentials in lib/carrierwave do you?Equally
Thanks John, Habe bundled and committed. Carrierwave talk of adding the file in the lib directory. I only have /config/initializers/carrierwave.rb should i have the file under the lib directory?Mailable
no, you're exactly right in config/initializers - lib/carrierwave is known to cause the error you're getting.Equally
C
0

It might not be the solution to your problem but it is worth a try adding

config.cache_dir = "#{Rails.root}/tmp/uploads". That will help keep the files around until they are uploaded to you S3 bucket.

If that does not help can you also post your uploader file?

Conn answered 3/1, 2012 at 23:12 Comment(1)
Thanks Yuri i will add that line. Much appreciated.Mailable

© 2022 - 2024 — McMap. All rights reserved.