【问题标题】:secret_key_base Error in Production Mode Ruby on Rails using HostGator使用 HostGator 的生产模式 Ruby on Rails 中的 secret_key_base 错误
【发布时间】:2017-03-19 00:13:13
【问题描述】:

我得到的错误:

App 1077 stderr: [ 2017-03-18 15:56:25.9166 1116/0x007f13c5aa39c8(Worker 1) utils.rb:87 ]: *** Exception RuntimeError in Rack application object (Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`) (process 1116, thread 0x007f13c5aa39c8(Worker 1)):

我的secrets.yml 中有此代码:

development:
  secret_key_base: f8eed700430c3828f1f3c84627b29de146e1c73bae55b31142b9339e95ca4962cf0922b3be80d0733fb0f03f35d00c7ea21dca205ffd0bdf1ae48cf4f874af86

test:
  secret_key_base: 452aa27249ce5eae3290bae7dec500baa0aa0a4bb963a9846aed4e67796d13abcc84d51369ca9f09e002b78f17a42e08e3f590dbb4bc53e197497a68e470eaf8

'# Do not keep production secrets in the repository,
'# instead read values from the environment.

production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

【问题讨论】:

  • 看看这一行'# Do not keep production secrets in the repository, '# instead read values from the environment.你应该把一个密钥放到环境文件中
  • 我该怎么做?最后一行不是这样做的吗?

标签: ruby-on-rails ruby production-environment production secret-key


【解决方案1】:

我通过转到 /environments/production.rb 并输入 config.secret_key_base = ENV["SECRET_KEY_BASE"] 来修复此错误

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-05
    • 1970-01-01
    • 1970-01-01
    • 2013-05-25
    • 1970-01-01
    • 2014-07-06
    • 2015-07-12
    • 1970-01-01
    相关资源
    最近更新 更多