title: Stripe - No API key provided?
body: <p>I'm struggling with this error No API key provided. Set your API key using "Stripe.api_key = ". You can generate API keys from the Stripe web interface in a Rails app after following step by step <a href="https://stripe.com/docs/checkout/guides/rails" rel="noreferrer">Stripe's guide</a>.</p>
  
  <p>From what I see, everything looks fine, but it keeps returning that notice. Any advice?</p>
  
  <p>Charges Controller:</p>
  
  <pre><code>  class ChargesController &lt; ApplicationController
  
      def new
      end
  
      def create
        # Amount in cents
        @amount = 500
  
        customer = Stripe::Customer.create(
          :email =&gt; 'example@stripe.com',
          :card  =&gt; params[:stripeToken]
        )
  
        charge = Stripe::Charge.create(
          :customer    =&gt; customer.id,
          :amount      =&gt; @amount,
          :description =&gt; 'Rails Stripe customer',
          :currency    =&gt; 'usd'
        )
  
      rescue Stripe::CardError =&gt; e
        flash[:error] = e.message
        redirect_to charges_path
      end
  
    end
  </code></pre>
  
  <p>config/initializers/stripe.rb</p>
  
  <pre><code>    Rails.configuration.stripe = {
        :publishable_key =&gt; ENV['pk_test_KEY'],
        :secret_key      =&gt; ENV['sk_test_KEY']
      }
  
      Stripe.api_key = Rails.configuration.stripe[:secret_key]
  </code></pre>
  
  <p>Terminal trace
          Started POST "/charges" for 127.0.0.1 at 2014-12-12 22:15:08 +0100</p>
  
  <pre><code>    Processing by ChargesController#create as HTML
  
        Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"XXX", "stripeToken"=&gt;"tok_1590kf2NNSl5uX0kXE9XXX", "stripeTokenType"=&gt;"card", "stripeEmail"=&gt;"USER@gmail.com"}
  
      Completed 500 Internal Server Error in 2ms
  
  
  
      Stripe::AuthenticationError - No API key provided. Set your API key using "Stripe.api_key = &lt;API-KEY&gt;". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email support@stripe.com if you have any questions.:
  
         () Users/javier/.rvm/gems/ruby-2.1.2/bundler/gems/stripe-ruby-9c7ebd21c973/lib/stripe.rb:71:in `request'
  
         () Users/javier/.rvm/gems/ruby-2.1.2/bundler/gems/stripe-ruby-9c7ebd21c973/lib/stripe/api_operations/create.rb:6:in `create'
  
         () Users/javier/Desktop/definitive/app/controllers/charges_controller.rb:10:in `create'
  </code></pre>
  
  <p>Tested including the keys in secrets.yml as @sealocal suggests in comments, but still the same issue:</p>
  
  <pre><code>development:
   secret_key_base: key
   publishable_key: anotherkey
   secret_key: anotherkey
  
  test:
   secret_key_base:key
  production:
   secret_key_base: &lt;%= ENV["SECRET_KEY_BASE"] %&gt;
   publishable_key: &lt;%= ENV["publishable_key"] %&gt;
   secret_key: &lt;%= ENV["secret_key"] %&gt;
  </code></pre>