Rails credentials are a little different in how they work and I ran into a few issues with them while trying to secure my application and remove all the secret keys from my application.
Common commands with Rails credentials:
rails credentials:edit --environment staging
bin/rails encrypted:edit config/your-enctyped-file.yml.enc --key config/your-master.key
I would highly reccommend upgrading to rails 6 for the multi environment credentials!
Editing Config/Secrets within Respective Environments
# Edit the development credentials in config/credentials/development.yml.enc
EDITOR=vim rails credentials:edit --environment development
# Edit the production credentials in config/credentials/production.yml.enc
EDITOR=vim rails credentials:edit --environment production
This last command will create a master key with the production keys. Note the vs code editor does not work so I use VIM.
Note with multi-environment credentials, the
RAILS_ENV must be specified for building and running webserver and other necessary commands.