I have recently deployed an app and got internal server error because of missing production secret_key_base. After hours of testing, I managed to solve this problem with two methods: Method 1: I generated a new secret_key with rake secret and replaced it with <%= ENV['SECRET_KEY_BASE'] %> in secrets.yml . Deployed the app again and this time it worked. But I think that this method is wrong.Method 2: I generated a new secret_key with rake secret and added it to environments/production.rb like config.secret_key_base = 'd1f4810e662acf46a33960e3aa5bd0************************ , without changing secrets.yml (default is production: <%= ENV['SECRET_KEY_BASE'] %> ). Deployed the app again and it works fine.My questions:
|
As the name implies, secret_key_base should be a secret. That's why we don't generate a secret for production in config/secrets.yml . You see that it's reading from an environment variable so you can easily set your secret on your production server, without changing the file:If you want / need to have your secret under version control, you should definitely stick with Method 1 . That's because Method 2 just avoids the config/secrets.yml mechanism all together.Please note that we don't use GitHub for support questions. Read our contribution guidelines and please use the rails-talk mailing list for further questions. |