I experienced this same issue when working on a Rails 5.2 application in production.
I already had other things set up. The problem for me was not that the secret_key_base
wasn't set properly, it was rather because of the Passing the environment's name as a regular argument like below is deprecated
rails c RAILS_ENV=production
If you look at your error log generated closely from its top you will see this:
DEPRECATION WARNING: Passing the environment's name as a regular argument is deprecated and will be removed in the next Rails version. Please, use the -e option instead. (called from at bin/rails:9)
To run the rails console in a different environment, use the -e option like this:
rails console -e production
Note: Setting the secret_key_base
in the secrets.yml
file is not safe, as it's not a secure way of storing the key, please use the encrypted credential.yml
file and the master key
to decrypt it.
That's all.
I hope this helps