Search code examples
ruby-on-railsdebuggingdevelopment-environmentstripe-paymentsproduction

Debugging initializer in rails


I'm debugging a stripe payments initializer in rails. I want it to notify me if the current environment is the production environment so I can see if Stripe is getting the right keys. How would you use an initializer to print to the console or put information in a view?

Edit - Here's the initializer

if Rails.env.production?
  Rails.configuration.stripe = {
    publishable_key: ENV[ 'PUBLISHABLE_KEY' ],
    secret_key:      ENV[ 'SECRET_KEY' ]
  }
else
  Rails.configuration.stripe = {
    publishable_key: 'pk_test_UQ2EqhNNQRrDkD5V0Z1xgpS5',
    secret_key:      'sk_test_hkiYUTQzHiCTBfHuUSXpUP7n'
  }
end

Solution

  • So I'm using Heroku. Running

    heroku run console
    

    runs a console in Heroku and

    Rails.env
    

    returns the environment.