Checking encrypted credentials into git using Rails 6 feels weird but is pretty great.
What isn’t great is getting this error when deploying to Heroku:
EDITOR=vim bundle exec rails credentials:edit Rails will create a master.key file which works fine, but expects all your environments to be in a single credentials file and creates a master.key to decrypt the file.
EDITOR=vim bundle exec rails credentials:edit --environment staging appears to not use the master key and instead autocreates a
In Heroku, the RAILS_MASTER_KEY environment variable needs to be set to the value of staging.key, not master.key, otherwise the MessageEncryptor error is thrown. This wasn’t clear to me from various tutorials and StackOverflow posts.