Not recognizing ENV variables in S3.yml in rails

I'm currently trying to customize Paperclip using the latest aws-sdkgem offered.

In 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 does not recognize ENV variables. I get 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 access and secret directly into a file, it works fine. At the same time, I tried to print both ENV variables in the views or in the console, I can see their values ​​in order.

I do not understand why this does not know.

+5
source share
1 answer

Solved!

I found the answer to this question here Ruby on Rails: can you put the Ruby code in the YAML configuration file?

: YAML ERB.

ENV <%= %> .

access_key_id: <%= ENV['S3_KEY'] %>
secret_access_key: <%= ENV['S3_SECRET'] %>
+9