Carrierwave and s3 with heroku error undefined met

2019-04-10 23:09发布

问题:

I'm trying to setup carrierwave and s3 with heroku. I'm following the carrierwave docs exactly: https://github.com/jnicklas/carrierwave

I've setup a bucket named testbucket in AWS, then I installed fog and created a new initializer with this inside :

CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider               => 'AWS',       # required
    :aws_access_key_id      => 'my_key_inside_here',       # required
    :aws_secret_access_key  => 'my_secret_access_key_here',       # required
    :region                 => 'eu-west-1'  # optional, defaults to 'us-east-1'
  }
  config.fog_directory  = 'testbucket'                     # required

end

Then inside my image_uploader.rb I set

 storage :fog

Is there something else I am missing??? Thanks for any help.

回答1:

If you're using carrier-wave 0.5.2, you have to look in the docs within the gem. They are different than what you see on github. Specifically, check out this file in the gem: lib/carrierwave/storage/s3.rb

Also set store to :s3...not :fog. You'll see this section:

#     CarrierWave.configure do |config|
#       config.s3_access_key_id = "xxxxxx"
#       config.s3_secret_access_key = "xxxxxx"
#       config.s3_bucket = "my_bucket_name"
#     end
#