rails ruby 中的内部服务器错误

Internal server error in ruby on rails

我试图打开我的根页面时显示错误 "Internal server error"

=> Booting Thin  

=> Rails 4.2.6 应用程序开始开发 http://localhost:4000
=> 运行 rails server -h 更多启动选项
=> Ctrl-C 关闭服务器
瘦网络服务器(v1.6.4 代号 Gob Bluth) 最大连接数设置为 1024 监听 localhost:4000,CTRL+C 停止
弃用警告:您没有设置 secret_key_base。阅读升级文档以了解有关此新配置选项的更多信息。 (从 /home/smk/test/test/BMS-New/bin/rails:9 处的 require 调用) 处理请求时发生意外错误:'development' 环境缺少 secret_tokensecret_key_base,请在 config/secrets.yml 中设置这些值 /home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/application.rb:534:in validate_secret_key_config!' /home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/application.rb:246:inenv_config' /home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/engine.rb:514:in call' /home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/application.rb:165:incall' /home/smk/test/test/BMS-New/vendor/bundle/gems/rack-1.6.4/lib/rack/content_length.rb:15:在 call' /home/smk/test/test/BMS-New/vendor/bundle/gems/thin-1.6.4/lib/thin/connection.rb:86:in 块中 pre_process' /home/smk/test/test/BMS-New/vendor/bundle/gems/thin-1.6.4/lib/thin/connection.rb:84:in catch' /home/smk/test/test/BMS-New/vendor/bundle/gems/thin-1.6.4/lib/thin/connection.rb:84:inpre_process' /home/smk/test/test/BMS-New/vendor/bundle/gems/thin-1.6.4/lib/thin/connection.rb:53:in process' /home/smk/test/test/BMS-New/vendor/bundle/gems/thin-1.6.4/lib/thin/connection.rb:39:inreceive_data' /home/smk/test/test/BMS-New/vendor/bundle/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in run_machine' /home/smk/test/test/BMS-New/vendor/bundle/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in运行' /home/smk/test/test/BMS-New/vendor/bundle/gems/thin-1.6.4/lib/thin/backends/base.rb:73:in start' /home/smk/test/test/BMS-New/vendor/bundle/gems/thin-1.6.4/lib/thin/server.rb:162:instart' /home/smk/test/test/BMS-New/vendor/bundle/gems/rack-1.6.4/lib/rack/handler/thin.rb:19:in run' /home/smk/test/test/BMS-New/vendor/bundle/gems/rack-1.6.4/lib/rack/server.rb:286:instart' /home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/commands/server.rb:80:in start' /home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:80:in服务器阻塞' /home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in tap' /home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:inserver' /home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in run_command!' /home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/commands.rb:17:in' /home/smk/test/test/BMS-New/bin/rails:9:在require' /home/smk/test/test/BMS-New/bin/rails:9:in' /home/smk/test/test/BMS-New/vendor/bundle/gems/spring-1.7.1/lib/spring/client/rails.rb:28:in load' /home/smk/test/test/BMS-New/vendor/bundle/gems/spring-1.7.1/lib/spring/client/rails.rb:28:incall' /home/smk/test/test/BMS-New/vendor/bundle/gems/spring-1.7.1/lib/spring/client/command.rb:7:in call' /home/smk/test/test/BMS-New/vendor/bundle/gems/spring-1.7.1/lib/spring/client.rb:30:in运行' /home/smk/test/test/BMS-New/vendor/bundle/gems/spring-1.7.1/bin/spring:49:in <top (required)>' /home/smk/test/test/BMS-New/vendor/bundle/gems/spring-1.7.1/lib/spring/binstub.rb:11:inload' /home/smk/test/test/BMS-New/vendor/bundle/gems/spring-1.7.1/lib/spring/binstub.rb:11:in <top (required)>' /usr/local/lib/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire' /usr/local/lib/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' /home/smk/test/test/BMS-New/bin/spring:13:in' bin/rails:3:在load' bin/rails:3:in'

在您的 config/secrets.yml 文件中删除所有内容并添加:

development:
  secret_key_base: bcbfd4e5010b035e62898f964188362877783b43f94bf883cf4b1d82d9224349789fb9dd0c2f33a200acfa266024a285e324caa3b20d0a9a352014156e47ec5c

test:
  secret_key_base: af068d8662bf954a2afeb27c64bbcdeb56b730029272bd3daff7e00c3c076999b3d2297747a3cef0550d3efd5cf8072e0477b8a62f096c94ab124f0d99320d20

# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

您的错误是指在您的 secrets.yml 文件中缺少 secret_key_basesecret_token

仅供参考: 您可以根据需要更改 secret_key_base。如果您没有此文件,请创建一个。对于不同的环境,secret_key_base 会有所不同。您还应该在那里添加环境。在这里,我给出development/production/test环境

的key base