缺少'secret_key_base`用于'生产'环境

Ged*_*nas 2 ruby-on-rails nginx ruby-on-rails-4

我的Missing 'secret_key_base' for 'production' environmentnginx error.log中有错误.当我打开我的秘密.时,我看到:

development:
  secret_key_base: 123...

test:
  secret_key_base: 321...

# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
Run Code Online (Sandbox Code Playgroud)

SECRET_KEY_BASE定义在哪里?我应该把它添加到某个地方吗?

因此,nginx显示502 Bad Gateway我的Rails应用程序.Rails版本4.1.1

tir*_*adc 7

它期望一个环境变量,您可以在自己的代码中,在bash配置文件中或在dotenv文件中设置自己的代码.

请参阅我的代码中是否可以为rails开发环境设置ENV变量?更多细节.

就个人而言,我只是将所有敏感的东西直接放在secrets.yml中,并将其保留在存储库中,因为这似乎是该文件的预期目的.

  • 注意:如果您使用RVM,"bash配置文件"方法略有不同:您需要将`export`行添加到`〜/ .rvm/environments/ruby​​-xxx`.请参阅https://groups.google.com/forum/#!topic/rubyversionmanager/LF2DxnpSlQU (4认同)