ruby-on-rails - Rails 从应用程序收到不完整的响应

标签 ruby-on-rails ruby apache passenger

Ubuntu 14.04.3 LTS(GNU/Linux 3.19.0-25-generic x86_64)
ruby 1.9.3p484(2013-11-22 修订版 43786)[x86_64-linux]
Rails 2.3.14
Apache/2.4.7 (Ubuntu)
Phusion Passenger 版本 5.0.21

App 6748 stderr: Error during failsafe response: "\xD0" from ASCII-8BIT to UTF-8
App 6748 stderr: 
[ 2015-11-20 12:58:26.6770 6711/7f2455b2f700 age/Cor/Req/Utils.cpp:96 ]: [Client 1-19] Sending 502 response: application did not send a complete response
App 6748 stderr: [ 2015-11-20 12:58:26.6772 7800/0x000000020fcf88(Worker 1) utils.rb:87 ]: *** Exception NoMethodError (You have a nil object when you didn't expect it!
App 6748 stderr: You might have expected an instance of ActiveRecord::Base.
App 6748 stderr: The error occurred while evaluating nil.[]) (process 7800, thread 0x000000020fcf88(Worker 1)):
App 6748 stderr:    from /usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:127:in `process_request'
App 6748 stderr:    from /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:152:in `accept_and_process_next_request'
App 6748 stderr:    from /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:113:in `main_loop'
App 6748 stderr:    from /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:416:in `block (3 levels) in start_threads'
App 6748 stderr:    from /usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'
[ 2015-11-20 12:58:31.0215 6711/7f245c2fd700 age/Cor/App/Poo/AnalyticsCollection.cpp:105 ]: Process (pid=7800, group=[application_folder] (development)) no longer exists! Detaching it from
the pool.
[ 2015-11-20 12:58:31.0215 6711/7f245c2fd700 age/Cor/CoreMain.cpp:794 ]: Disconnecting long-running connections for process 7800, application [application_folder] (development)
App 7852 stdout: 

我尝试将所有 Controller 源文件转换为 UTF-8 格式,并在文件开头添加 #encoding: utf-8。尝试将 key 添加到 app/secret.yml,重新启动服务器,但没有任何反应。

Apache 日志说明了一些关于 ActiveRecord::Base 的内容。但我只生成了一些模型,并没有触及 app/models/* 中的文件。

最佳答案

这是因为我在 Controller 中使用了 unicode 符号。
当我将 RAILS_ROOT/app/controllers/* 中所有 Controller 的编码设置为 UTF-8 而不是 UTF-8 without BOM 时一切正常.

关于ruby-on-rails - Rails 从应用程序收到不完整的响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33824133/

相关文章:

apache - 在 openshift 上,我的 tomcat 服务器前面是否有任何 apache?

php - 如何更改 WampServer 3 上的 www 根目录

ruby-on-rails - Rails ActiveRecord::Base before_save 覆盖 write_ 访问器以保存电话号码

ruby - 从Rails应用程序调用Chef更新命令时出现Encoding::UndefinedConversionError

ruby-on-rails - 您希望看到哪些 Rails 插件?

ruby-on-rails - 1 个 Heroku dyno 上有多少个 Rails 应用程序?

apache - 相同的域 - 2 个独立的服务器

ruby-on-rails - Ruby on Rails : what performance can I realistically aim for?

ruby-on-rails - Rails Elastic Beanstalk nginx 301 重定向

jquery - Rails - AJAX 模式对话框?