Rails 7, HatchBox and the Rails Master Key
I’ve written this before, I’ll likely write it again as it is something I struggle with EVERY SINGLE TIME I deploy something new onto HatchBox (note I use HatchBox classic).
HatchBox requires the Rails Master Key. This is NOT, repeat NOT:
cat config/master.key
This is instead:
cat config/credentials/production.key
I don’t know if this is a nomenclature failure on the part of HatchBox or on Rails 7 but the disconnect between the software asking for “The Rails Master Key” and it instead being given the file production.key always makes my brain hurt.
Sidebar: If You Aren’t Using JumpStart / A Missing config/credentials Directory
When you build a Rails app using JumpStart, the directory config/credentials will be present in your application as JumpStart builds that for you. But if you are starting fresh then that directory is going to be missing and here’s how to create it:
EDITOR=nano bin/rails credentials:edit --environment production
You will then get a message like this:
Adding config/credentials/production.key to store the encryption key: DELETED_FOR_SAFETY
Save this in a password manager your team can access.
If you lose the key, no one, including you, can access anything encrypted with it.
create config/credentials/production.key
Ignoring config/credentials/production.key so it won't end up in Git history:
append .gitignore
File encrypted and saved.
See Also: Stack Overflow