fog: Declaring only fog-aws in Gemfile: uninitialized constant CarrierWave::Storage::Fog
In an effort to load only the fog service gem we’re using, I’m declaring only fog-aws in the Gemfile:
gem fog-aws
However, on Rails console boot:
uninitialized constant CarrierWave::Storage::Fog
# backtrace line: ~/app/config/initializers/carrierwave.rb:4 (see below)
I’ve googled and stackoverflowed for examples of using specific service gems only. No luck.
Anyone know which gems to include to fix this? I would post in the Carrierwave project but this is only a problem when declaring fog-aws instead of fog.
Rails 4.1.8
Ruby 2.2
Fog 1.27
# initializer file
CarrierWave.configure do |config|
if EnvInq.asset_store_on?
config.cache_dir = "#{Rails.root}/tmp/"
config.storage = :fog
config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: EnvInq.aws_access_key_id,
aws_secret_access_key: EnvInq.aws_secret_access_key
}
config.asset_host = "https://#{EnvInq.asset_host}" if EnvInq.asset_host.present?
config.fog_directory = EnvInq.aws_s3_bucket
config.fog_public = true
config.fog_attributes = { cache_control: 'max-age=315576000', expires: 1.year.from_now.httpdate }
else
config.storage = :file
end
end
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 20 (7 by maintainers)
Since
requireworks with$LOAD_PATHand my Rails app haslibin its load path, I did the following:where the file contains the following:
and then in my CarrierWave initializer I did the following:
the app then works with
fog-aws.Defining config.fog_credentials before config.storage = :fog worked for me, as referenced in this post #https://github.com/carrierwaveuploader/carrierwave/issues/2023
@kevin-bockman @geemus I was having the same issue. Moving the
config.storageassignment afterconfig.fog_*assignments fixed the problem for me.This was problematic:
This works:
The above solution did not work. Seems this bug still exist.
@kburzota sorry to hear it took so long, but glad you found your solution. Thanks for sharing, hopefully that can help others that might run into this as well.
@evadne 's solution solved it for me. Thanks so much!