NameError: uninitialized constant CarrierWave :: Storage :: Fog in Heroku logs

Hello, I just added AWS S3 Bucket to my application.

Here is the app error https://dry-atoll-6663.herokuapp.com/

In heroku logs when i $ heroku restarts this error, it appears

2015-04-28T09:13:15.009823+00:00 app[web.1]: [3] ! Unable to load application: NameError: uninitialized constant CarrierWave::Storage::Fog

      

My Carrierwave.rb

CarrierWave.configure do |config|
config.fog_credentials = {
  # Configuration for Amazon S3
  :provider              => 'AWS',
  :aws_access_key_id     => ENV['S3_ACCESS_KEY'],
  :aws_secret_access_key => ENV['S3_SECRET_KEY']
}
config.fog_directory     =  ENV['S3_BUCKET']
end

      

Any ideas? Me and my friend scratch our heads for a very long time ...

+3


source to share


3 answers


Credit @Marcus for the correct answer to this in the comments.

In your file, config/initializers/carrierwave.rb

you will need to update

CarrierWave.configure do |config|
  # This is the old way, and broken
  config.storage = :fog

      



in

CarrierWave.configure do |config|
  # This is the new way!
  config.fog_provider = 'fog/aws'

      

see the github framework for more information.

+2


source


After pulling my hair out for a couple of hours, I finally decided that it looks like a recent issue withcarrierwave (0.10.0)

Thanks to GitHub user trantorLiu , this fixed me:

I also ran into this problem. I fixed it by specifying an older Carrierwave Version in Gemfile.lock.

Here is my Gemfile.lock. The version 37cf31d

doesn't work for me, so I'm rolling back to cb1a5bf

. And then everything worked as before.

GIT
  remote: git://github.com/carrierwaveuploader/carrierwave.git
  revision: cb1a5bfc6601a4e5d0abb6bad17911d73dcb57e3
  specs:
    carrierwave (0.10.0)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
      json (>= 1.7)
      mime-types (>= 1.16)

      

Here is my Gemfile. FYI.

gem 'fog', require: 'fog/aws'
gem 'carrierwave', github: 'carrierwaveuploader/carrierwave'

      



Also, if it helps, here's my config/initializers/carrierwave.rb

:

CarrierWave.configure do |config|
  if Rails.env.development?
    config.storage = :file
  elsif Rails.env.test?
    config.storage = :file
    config.enable_processing = false
  else
    config.storage = :fog
    config.fog_credentials = {
      provider:               'AWS',
      aws_access_key_id:      Rails.configuration.aws.access_key_id,
      aws_secret_access_key:  Rails.configuration.aws.secret_access_key,
    }
    config.fog_directory  = Rails.configuration.files.aws_bucket
  end
end

      

+1


source


After further consideration, I decided to drop it entirely fog

. I ended up using carrierwave-aws

. The configuration is almost identical.

My new one config/initializers/carrierwave.rb

:

CarrierWave.configure do |config|
  if Rails.env.development?
    config.storage = :file
  elsif Rails.env.test?
    config.storage = :file
    config.enable_processing = false
  else
    config.storage = :aws
    config.aws_bucket = Rails.configuration.files.aws_bucket
    config.aws_acl = 'public-read'
    config.aws_credentials = {
      access_key_id: Rails.configuration.aws.access_key_id,
      secret_access_key: Rails.configuration.aws.secret_access_key,
      region: Rails.configuration.aws.region,
    }
  end
end

      

+1


source







All Articles