title: Rails: constant not initializing
body: <p>I am trying to use different stripe keys (a credit card payment processing system) depending on whether I'm in test/development or production/ Based on suggestions I've seen on StackOverflow, I did the following:</p>
  
  <p>In my /config/initalizers/stripe.rb file, I have the following:</p>
  
  <pre><code>STRIPE_CONFIG = begin
    config = YAML.load(File.open(Rails.root.join('config', 'stripe.yml')))
    config = config[Rails.env] || {}
    config.to_options
  end
  </code></pre>
  
  <p>and in my /config/stripe.yml file, I have the following:</p>
  
  <pre><code>default: &amp;default
    Stripe.api_key:    "testapikeycode"
    STRIPE_PUBLIC_KEY: "testpublickeycode"
  
  development:
    &lt;&lt;: *default
  
  test:
    &lt;&lt;: *default
  
  production:
    Stripe.api_key:    "productionapikeycode"
    STRIPE_PUBLIC_KEY: "productionpublickeycode"
  </code></pre>
  
  <p>However, when I go into the console (rails console), and I type</p>
  
  <pre><code>puts STRIPE_PUBLIC_KEY
  </code></pre>
  
  <p>I get the following error message:</p>
  
  <pre><code>NameError: uninitialized constant STRIPE_PUBLIC_KEY
  </code></pre>
  
  <p>Any ideas?</p>
  
  <h1>Alternate method</h1>
  
  <p>Only use stripe.rb, and have the following in it:</p>
  
  <pre><code>if Rails.env == 'production'
    Stripe.api_key:    "productionapikeycode"
    STRIPE_PUBLIC_KEY: "productionpublickeycode"
  else
    Stripe.api_key:    "tesapikeycode"
    STRIPE_PUBLIC_KEY: "testpublickeycode"     
  end 
  </code></pre>