Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
507 views
in Technique[技术] by (71.8m points)

ruby on rails - heroku - Missing required arguments: aws_access_key_id, aws_secret_access_key, following Hartl tutorial

Running heroku run rake db:migrate, I get this error: Missing required arguments: aws_access_key_id, aws_secret_access_key.

I made the correction recommended in SO question 25596504, specifically changing the file carrier_wave.rb to carrierwave.rb with no luck. I am following the Hartl tutorial page 688 which specifies adding them as $heroku config:set S3_ACCESS_KEY=<access key> I replaced the '' with quoted and unquoted versions of the actual key. The keys show when I run heroku config, e.g., S3_ACCESS_KEY:

The application was working before I began working on this section (11.4) of the tutorial re uploading images. I, incidentally, know about the Figaro gem; however, I'd like to try following the tutorial's approach. What am I missing? Any thoughts would be appreciated. Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Go on Heroku, on your application, go to settings, hit Reveal Config Vars.

Click on on Edit on the right side and enter your secrets there:

S3_BUCKET: name of your bucket goes here
S3_ACCESS_KEY: xxxxx
S3_SECRET_KEY: xxxx

On config/initializers/carrierwave.rb or wherever you're entering your secrets should have:

CarrierWave.configure do |config|
  config.root = Rails.root.join('tmp') # adding these...
  config.cache_dir = 'carrierwave' # ...two lines

  config.fog_credentials = {
    :provider               => 'AWS',                        # required
    :s3_access_key_id      => ENV['S3_ACCESS_KEY'],                        # required
    :s3_secret_access_key  => ENV['S3_SECRET_KEY'],                     # required
    :region                 => 'eu-west-1',                  # optional, defaults to 'us-east-1'
    :host                   => 's3.example.com',             # optional, defaults to nil
    :endpoint               => 'https://s3.example.com:8080' # optional, defaults to nil
  }
  config.fog_directory  = ENV['S3_Bucket']                             # required
  config.fog_public     = false                                   # optional, defaults to true
  config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}  # optional, defaults to {}
end

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...