2011-09-16 19 views
0

初めてアプリケーションをロードするときにエラーが発生します。すぐにページをリロードすると、アプリケーションは正常に読み込まれます。これは開発に大きな問題ではありませんが、実際にはエラーをキャッシュしているようです。私はruby 1.9.2-p136、1.9.2-p180、1.9.2-p290を試しましたが、それらはすべて同じように見えます。以下は、DEVELOPMENT環境からの出力です。さらに下に行くと、おそらくNoMethodErrorをキャッシュしている、502のBad Gatewayをもたらすnginxのログです。以下Ruby on RailsのNoMethodErrorは最初のロード時のみ

$ rails s 
=> Booting WEBrick 
=> Rails 3.0.5 application starting in development on http://0.0.0.0:3000 
=> Call with -d to detach 
=> Ctrl-C to shutdown server 
[2011-09-16 19:13:39] INFO WEBrick 1.3.1 
[2011-09-16 19:13:39] INFO ruby 1.9.2 (2011-07-09) [i686-linux] 
[2011-09-16 19:13:39] INFO WEBrick::HTTPServer#start: pid=2260 port=3000 

Started GET "/" for 127.0.0.1 at 2011-09-16 19:13:42 -0400 

NoMethodError (undefined method `[]' for false:FalseClass): 

Rendered /home/paisley/tool/install/ruby-1.9.2-p290-fts/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.9ms) 
Rendered /home/paisley/tool/install/ruby-1.9.2-p290-fts/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (6.2ms) 
Rendered /home/paisley/tool/install/ruby-1.9.2-p290-fts/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (11.1ms) 

Started GET "/" for 127.0.0.1 at 2011-09-16 19:13:44 -0400 
    Processing by WelcomeController#index as HTML 
Rendered welcome/index.haml within layouts/application (13.6ms) 
Completed 200 OK in 18ms (Views: 17.5ms) 

nginxのエラーログ:

2011/09/16 19:21:29 [error] 15002#0: *30 upstream prematurely closed connection while reading response header from upstream, client: 74.71.201.247, server: redacted.com, request: "GET/HTTP/1.1", upstream: "passenger:unix:/passenger_helper_server:", host: "redacted.com" 
[ pid=19637 thr=74145680 file=utils.rb:176 time=2011-09-16 19:21:29.767 ]: *** Exception NoMethodError in application (undefined method `[]' for false:FalseClass) (process 19637, thread #<Thread:0x8d6bf20>): 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:59:in `establish_connection' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/railtie.rb:59:in `block (2 levels) in <class:Railtie>' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/lazy_load_hooks.rb:42:in `each' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/base.rb:1900:in `<top (required)>' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/utils.rb:397:in `before_handling_requests' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/rack/application_spawner.rb:204:in `start_request_handler' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/rack/application_spawner.rb:170:in `block in handle_spawn_application' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/utils.rb:479:in `safe_fork' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/rack/application_spawner.rb:165:in `handle_spawn_application' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server.rb:180:in `start' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/rack/application_spawner.rb:128:in `start' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize' 
    from <internal:prelude>:10:in `synchronize' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously' 
    from /opt/tool/install/ruby-1.9.2-p180-tasks/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/helper-scripts/passenger-spawn-server:99:in `<main>' 

任意のアイデア?

+0

このエラーは、config/database.ymlを使用しないことによって発生したようです。一度そのファイルを埋めれば、アプリケーションはActiveRecordを使用しないか、モデルを持っていても動作します。私はこれをそこに残しておいて、実際に何が起こっているのか理解できるかどうかを確認します。 –

答えて

0

アプリケーションでActiveRecordが使用されていない場合は、プロジェクトを少し異なるように設定する必要があります。あなたのGemfileに

、代わりに追加 'レール' は、単にこれらを追加します。

のActiveRecord以外のRailsのすべてをだ
RAILS_VERSION = '~> 3.0' 

gem 'activesupport',  RAILS_VERSION, :require => 'active_support' 
gem 'actionpack',   RAILS_VERSION, :require => 'action_pack' 
gem 'actionmailer',  RAILS_VERSION, :require => 'action_mailer' 
gem 'railties',   RAILS_VERSION, :require => 'rails' 

今、あなたはまた、あなたのconfig/application.rbを変更する必要があり、その代わりにrequire "rails"の、それだけで行います。

require "action_controller/railtie" 
require "action_mailer/railtie" 
require "rails/test_unit/railtie" 

あなたがテスト::ユニットを使用していない場合は、上記の抜粋からそのrailtieを削除。

+0

このソリューションでは、config/database.ymlを持つ必要はありません。完璧、ありがとう。 –

関連する問題