Skip to content

Latest commit

 

History

History
11 lines (6 loc) · 850 Bytes

generate-a-rails-secret-key.md

File metadata and controls

11 lines (6 loc) · 850 Bytes

Generate a Rails Secret Key

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.