Chakreshwar Sharma
Chakreshwar Sharma

Reputation: 2610

NameError (uninitialized constant Aws::VERSION):

I am integrating paperclip with S3 bucket in RAILS 5. I am referring https://coderwall.com/p/vv1iwg/set-up-ruby-on-rails-with-paperclip-5-and-s3-using-aws-sdk-v2. I have written the following in my development.rb:

  config.paperclip_defaults = {
    storage: :s3,
    s3_region: 'us-west-2',
    s3_credentials: {
      bucket: 'mybucket',
      access_key_id: 'my id',
      secret_access_key: 'my secret key'
      }
    } 

I am getting the below error while uploading image:

NameError (uninitialized constant Aws::VERSION):

I am using version 3.0.1 of gem aws-sdk

Upvotes: 4

Views: 1444

Answers (3)

Peter DeWeese
Peter DeWeese

Reputation: 18333

Instead of downgrading, you can introduce the variable that paperclip is missing in the current version. Adding this file works with aws-sdk 3.0.1 and paperclip 5.1.0, and will probably work until paperclip is updated to accommodate the aws changes.

# config/initializers/aws.rb
Aws::VERSION =  Gem.loaded_specs["aws-sdk"].version

Upvotes: 7

Chakreshwar Sharma
Chakreshwar Sharma

Reputation: 2610

I have downgraded the aws-sdk version to aws-sdk (2.10.42) and it works.

Upvotes: 3

Alex Zakruzhetskyi
Alex Zakruzhetskyi

Reputation: 1433

Here is my config for CarrierWave with minimagick, I think something similar can be done for your case:

config/initializers/carrier_wave.rb

CarrierWave.configure do |config|       
     config.fog_credentials = {     
         provider:              'AWS',      
         aws_access_key_id:     ENV['S3_ACCESS_KEY'],       
         aws_secret_access_key: ENV['S3_SECRET_KEY'],       
         region:                ENV['S3_REGION']        
     }      
     config.fog_directory     =  ENV['S3_BUCKET']       
 end

Upvotes: 0

Related Questions