Here's my carrierwave config file:
CarrierWave.configure do |config|
config.storage = :aws
config.aws_bucket = ENV.fetch('S3_BUCKET_NAME')
config.aws_acl = :public_read
config.asset_host = 'http://example.com'
config.aws_credentials = {
access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY')
}
end
The server won't start and returns:
14:53:23 web.1 | /home/tom/paul/config/initializers/carrierwave.rb:9:in `fetch': key not found: "AWS_ACCESS_KEY_ID" (KeyError)
I entered the keys like this in the command line:
export AWS_ACCESS_KEY_ID="demo12345"
both with and without the quote marks
the command
env
displays them OK
I would use the Gem 'Figaro' to help manage environment variables. Very easy to set-up and manage.
1) Add to your Gemfile and bundle:
gem 'figaro', '1.0'
2) run 'figaro install'
figaro install
3) Open up the generated file: config/application.yml and add the variables:
SAMPLE_PASSWORD: exAmplePa$$
SAMPLE_USERNAME: myspecialusername
4) Go back into your initializer file and change your variable too:
user_name: ENV['SAMPLE_USERNAME'],
password: ENV['SAMPLE_PASSWORD'],
You should be good to go!
You should be changed/edit in config/environments/development.rb as it:
S3_BUCKET_NAME= ******your bucket name ****
AWS_ACCESS_KEY_ID= ******your acess key_id***
AWS_SECRET_ACCESS_KEY= ********* your secret key ***
AWS_REGION= ******* your region ***
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.