1
votes

I am unable to set secret_key_base for the production environment in Ruby on Rails 4.1.4 application running on Heroku.

Here are the steps that I've tried to do:

  • Run rake secret and copy the secret key to the clipboard

  • Run heroku config:set SECRET_KEY_BASE=%SECRET_KEY%

It returns success and Heroku lists this environment variable in the dashboard on the site, but the application still thinks that the secret key was not provided:

Missing secret_key_base for 'production' environment, set this value in config/secrets.yml

Why? What am I doing wrong? How can I fix it?

Thanks in advance.

2

2 Answers

1
votes

Add config/secrets.yml to version control and deploy again. You might need to remove a line from .gitignore so that you can commit the file.

.gitignore Github created for my Rails application included config/secrets.yml


OR

Follow this steps:

  1. $ heroku config (run this command in your terminal)
  2. Copy value from SECRET_KEY_BASE
  3. paste value to secrets.yml file in place of <%= ENV["SECRET_KEY_BASE"] %> (without any quote)

e.g

production:
  secret_key_base: b1de60dd9e00816d0569c5ce3f8dbaa3c8ea4a7606120dc66cXXXXXXXXXXXXXXXXXXXXXX
  1. re-deploy

Note: Actually this is not safe but in-case you just wanted to run your app temporary in production mode for testing or in emergency condition

I hope it works for you...

0
votes

What is in your config/secrets.yml? For production it should contain the lines:

production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>