title: Using Figaro and Secrets.yml to Manage Env Variables
body: <p>I have a rails 4.1 app and I'm trying to organize my env variables. As of right now I have a secrets.yml file in my config/ folder. I also installed the figaro gem. My goal was to have all my env variables in the application.yml (not checked into git) file and then use the secrets.yml (checked into git) file to map the variables from appliation.yml to the application. When I print the files using Rails.application.secrets It just shows hashes that look like this:</p>
  
  <pre><code>:salesforce_username=&gt;"ENV['SALESFORCE_USERNAME']"
  </code></pre>
  
  <p>None of my external services are working with this env variables setup. When I view the traces, the actually ENV['ACCOUNT_ID'] are being passed through in the requests like this:</p>
  
  <pre><code>v2/accounts/ENV['ACCOUNT_ID']/envelopes
  </code></pre>
  
  <p>In addition, I cannot access my env variables using Rails.application.secrets.account_id in my app.</p>
  
  <p><strong>secrets.yml</strong></p>
  
  <pre><code>development:
    account_id: &lt;%= ENV['ACCOUNT_ID'] %&gt;
  </code></pre>
  
  <p><strong>aplication.yml</strong></p>
  
  <pre><code>development:
    ACCOUNT_ID: "123456"
  </code></pre>
  
  <p><strong>application.rb</strong></p>
  
  <pre><code># preload tokens in application.yml to local ENV
  config = YAML.load(File.read(File.expand_path('../application.yml', __FILE__)))
  config.merge! config.fetch(Rails.env, {})
  config.each do |key, value|
    ENV[key] = value.to_s unless value.kind_of? Hash
  end
  </code></pre>