If your master.key has been compromised, you might want to regenerate it.
No key regeneration feature at the moment. We have to do it manually.
- Copy content of original credentials
rails credentials:showsomewhere temporarily.
EDITOR=vim rails credentials:editin the terminal: This command will create a new
credentials.yml.encif they do not exist.
- Paste the original credentials you copied (step 1) in the new credentials file (and save + quit vim)
- Add and Commit the file
- Make sure
config/master.keyis listed in
.gitignoreand NOT tracked by git.
- The command
EDITOR=vim rails credentials:editmight not work if you require credential value in some file (
database.yml). I had the problem with
devise.rb. I just uncommented the line
secret_key = ...just the time to run the command to regenerate the credentials file, and then commented the line out again.
- If you want to use Sublime to edit the credentials, you can replace the command
EDITOR=vim rails credentials:editby
EDITOR="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -w" rails credentials:edit