Have you ever wondered about those secret keys found in config/secrets.yml
of your Rails app? The comments generated in that file describe the keys as 'used for verifying the integrity of signed cookies.'
Great... but what if they become compromised? Or we need to change them? We can generate new ones.
Rails provides rake secret
for just this purpose.
The source code is here. It's pretty simple; the code simply requires SecureRandom
and spits out a string. If you want to be really clever, you can pipe the string directly into your Vim buffer for the config file, with :.! rake secret
.
Check out rake -T | grep secret
inside a Rails root directory for more information.