title: Correct way for Storing API keys to credentials.yml.enc?
body: <p>I'm trying to store my API keys for Stripe Elements..You can see my previous post here: <a href="https://stackoverflow.com/questions/52982281/using-javascript-for-stripe-elements/52982419?noredirect=1#comment92872994_52982419">Using javascript for Stripe Elements</a></p>
  
  <p>As you can see, the Stripe Elements isn't showing up with the JS from Stripe or my stripejs.js file.</p>
  
  <p>I am assuming its the <a href="https://js.stripe.com/v3/" rel="nofollow noreferrer">https://js.stripe.com/v3/</a> that's not showing up somehow due to my API keys not storing correctly.  I currently have my API keys stored in my .env file managed by the dotenv gem</p>
  
  <p>I'm trying to store my API keys with credentials.yml.enc but not sure if I am doing it correctly.</p>
  
  <p><strong>What I do:</strong> </p>
  
  <p>Call "EDITOR=atom rails credentials:edit" in CMD.
  Atom pops up.
  I store API keys the following way:
  PUBLISHABLE_KEY = pk_test_1111111111111111111
  SECRET_KEY = sk_test_11111111111111111111</p>
  
  <p>Save the file.
  Exit.</p>
  
  <p>Although, it won't work.  Am i not storing it correctly? Doing something wrong?</p>
  
  <p>In my stripe.rb file under initializers is:</p>
  
  <pre><code>Rails.configuration.stripe = {
    :publishable_key =&gt; ENV['PUBLISHABLE_KEY'],
    :secret_key      =&gt; ENV['SECRET_KEY']
  }
  
  Stripe.api_key = Rails.configuration.stripe[:secret_key]
  </code></pre>
  
  <p>Edit:</p>
  
  <p>I have my stripe.rb file structured like this:</p>
  
  <pre><code>Rails.configuration.stripe = {
    :publishable_key =&gt; Rails.application.credentials.stripe[:publishable_key],
    :secret_key      =&gt; Rails.application.credentials.stripe[:secret_key]
  }
  
  Stripe.api_key = Rails.configuration.stripe[:secret_key]
  </code></pre>
  
  <p>and then saved my credentials files like this:</p>
  
  <pre><code>stripe:   
      publishable_key: 123456789
      secret_key: 123456789
  </code></pre>
  
  <p>I then receive the error when starting my servier: </p>
  
  <pre><code>undefined method \credentials' for Rails:Module (NoMethodError)`
  </code></pre>
  
  <p>Is there something wrong I'm doing?</p>
  
  <p>Attempt: 2:</p>
  
  <p>I tried doing in the stripe.rb file...</p>
  
  <pre><code>Rails.configuration.stripe = {
    Rails.application.credentials.stripe[:publishable_key],
    Rails.application.credentials.stripe[:secret_key]
  }
  
  Stripe.api_key = Rails.configuration.stripe[:secret_key]
  </code></pre>
  
  <p>with and withou tthe last time... I get the error: "syntax error, unexpected '}', expecting end-of-input"</p>
  
  <p>UPDATE:</p>
  
  <p>in case anyone comes across this with a similar issue...</p>
  
  <p>For me, it was bootstrap causing the problems. All you need to do is use class="form-control" within the Stripe Elements form for it to display correctly - if you're using Bootstrap.</p>