Rails从应用程序收到不完整的响应

时间:2015-11-20 10:16:41

标签: 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 revision 43786) [x86_64-linux]
Rails 2.3.14
Apache/2.4.7 (Ubuntu)
Phusion Passenger version 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: 

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

Apache日志说明ActiveRecord::Base。但是我只生成了一些模型而没有触及app/models/*中的文件。

1 个答案:

答案 0 :(得分:0)

这导致我在控制器中使用unicode simbols 当我将<?php ob_start(); //------------------Database section------------------------------------------ include('database.php'); //------------------Get the data ------------------------------------------ $title = $_GET['title1']; $type = $_GET['radio']; $url = $_GET['url']; // ----------------------add ----------------------------------- if ($type == "k") { $IS = $_GET['IS']; $qry ="SELECT k_name FROM k where ISSN = '".$IS."'"; $result = mysql_query($qry); if (mysql_num_rows($result) == 1) { echo '2'; } else { $qry1 = "insert into k (`k_name`, `IS`, `URL`, `is_r`) values('" . $title . "','" . $IS . "','" . $url . "',1);"; $result1 = mysql_query($qry1); if ($result1) { echo '1'; } } } ?> 中的所有控制器的编码设置为RAILS_ROOT/app/controllers/*而不是UTF-8时,一切正常。