ruby-on-rails – SemiFixed:缺少’secret_key_base`用于’生产’环境

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – SemiFixed:缺少’secret_key_base`用于’生产’环境前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我从头开始创建了一个rails应用程序(Rails 4.1.0),我遇到了一个我无法解决的问题.我已经安装并配置了Apache Passenger Module,它运行正常.每当我尝试访问虚拟主机时,都会收到错误500:
Missing secret_key_base for 'production' environment,set this value in config/secrets.yml

secret.yml文件包含以下配置:

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

即使我不建议我这样做:

production:
  secret_key_base: XXXXXXXXXXXXXXXXXXXXXXXXXXXX (random key)

但Apache日志显示

# tailf /etc/httpd/logs/error_log
[Tue May 06 12:56:18 2014] [error] [client 192.168.3.1] Premature end of script headers:
App 4405 stderr: [ 2014-05-06 12:56:18.5763 4421/0x9d48bdc(Worker 1) utils.rb:68 ]: *** Exception RuntimeError in Rack application object (Missing `secret_key_base` for 'production' environment,set this value in `config/secrets.yml`) (process 4421,thread 0x9d48bdc(Worker 1)):
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/application.rb:440:in `validate_secret_key_config!'
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/application.rb:195:in `env_config'
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:510:in `call'
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/application.rb:144:in `call'
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/lib/phusion_passenger/request_handler.rb:448:in `block (3 levels) in start_threads'

我该如何解决这个错误?我如何访问开发环境?我的意思是我如何编写代码,在浏览器中测试然后部署到Heroku或只是在生产环境中进行测试?

更新

我设法通过在VirtualHost上设置RailsEnv开发来修复上面的错误,但现在我得到了另一个错误

sqlite3::CantOpenException unable to open database file
Rails.root: /var/www/html/moviedb

我正在尝试使用this GEM对TheMovieDB网站进行查询并获得结果.有关此新错误的任何建议吗?

解决方法

我做了什么:在我的生产服务器上,我为Thin创建了一个配置文件(confthin.yml)(我正在使用它)并添加以下信息:

环境:生产
用户:www-data
组:www-data
SECRET_KEY_BASE:mysecretkeyproduction

然后我启动应用程序

瘦启动-C /whereeveristhefieonprod/configthin.yml

像魅力一样工作,然后无需在版本控制上使用密钥

希望它可以提供帮助,但我相信Unicorn和其他人可以做同样的事情.

原文链接:https://www.f2er.com/ruby/271230.html

猜你在找的Ruby相关文章