I'm currently trying to configure Paperclip with newest aws-sdk
suggested gem.
On my S3.yml file I have something like this
development:
bucket: newmeeter-dev
access_key_id: ENV['S3_KEY']
secret_access_key: ENV['S3_SECRET']
But it is not recognizing the ENV variables. I'm getting the following error
AWS::S3::Errors::InvalidAccessKeyId in PhotosController#create
The AWS Access Key Id you provided does not exist in our records.
If I try to put both the access and secret directly into the file it works perfectly. At the same time I tried to print both ENV variables into the views or in the console I can see their values okay.
I'm not getting why it is not recognizing it.
Solved!
I found the reply to this question here Ruby on Rails: Can you put Ruby code in a YAML config file?
Solution: YAML files understand code in ERB format.
Printing ENV variables inside <%=
and %>
works.
access_key_id: <%= ENV['S3_KEY'] %>
secret_access_key: <%= ENV['S3_SECRET'] %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With