2010-12-31 13 views
28

私はruby nubyです(そして、Stack Overflowに新しくなりました)Rails Tutorial by Michael Hartlと突然私の開発サーバーwon't load and keeps exitingで働いています。コンソールもロードされず、Rspec spec/errors/exceptionsが生成されます。私は端末からの出力をいくつか含めていますが、あなたの助けは大いに感謝しています。開発サーバーがロードされないのはなぜですか?

Exiting 
/Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:164:in `default_controller_and_action': missing :action (ArgumentError) 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:68:in `normalize_options!' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:51:in `initialize' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:261:in `new' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:261:in `match' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1112:in `match' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1297:in `match' 
    from /Users/ameedachowdhury/rails_projects/railstutorial/config/routes.rb:11:in `block in <top (required)>' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:233:in `instance_exec' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:233:in `draw' 
    from /Users/ameedachowdhury/rails_projects/railstutorial/config/routes.rb:1:in `<top (required)>' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `block in load' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `block in load_dependency' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application.rb:127:in `block in reload_routes!' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application.rb:127:in `each' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application.rb:127:in `reload_routes!' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application.rb:120:in `block in routes_reloader' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/file_update_checker.rb:32:in `call' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/file_update_checker.rb:32:in `execute_if_updated' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application/finisher.rb:51:in `block (2 levels) in <module:Finisher>' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application/finisher.rb:52:in `call' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application/finisher.rb:52:in `block in <module:Finisher>' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `block in run_initializers' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing' 
    from /Users/ameedachowdhury/rails_projects/railstutorial/config/environment.rb:5:in `<top (required)>' 
    from /Users/ameedachowdhury/rails_projects/railstutorial/config.ru:3:in `require' 
    from /Users/ameedachowdhury/rails_projects/railstutorial/config.ru:3:in `block in <main>' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize' 
    from /Users/ameedachowdhury/rails_projects/railstutorial/config.ru:1:in `new' 
    from /Users/ameedachowdhury/rails_projects/railstutorial/config.ru:1:in `<main>' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/rack-1.2.1/lib/rack/builder.rb:35:in `eval' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/rack-1.2.1/lib/rack/builder.rb:35:in `parse_file' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/rack-1.2.1/lib/rack/server.rb:162:in `app' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/rack-1.2.1/lib/rack/server.rb:248:in `wrapped_app' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/rack-1.2.1/lib/rack/server.rb:213:in `start' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/commands/server.rb:65:in `start' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/commands.rb:30:in `block in <top (required)>' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/commands.rb:27:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>' 
ameeda-chowdhurys-macbook:railstutorial ameedachowdhury$ 

答えて

69

私はこの問題に遭遇した場合controller#action構文を使用する場合routes.rbにおける経路の1つではなくハッシュ(#)のスラッシュ(/)を有していたので、それは(私は/」コントローラを使用しましたアクション "、これは間違っていた)。

たとえば、私は偶然root :to => 'home/index'を持っていました。それはroot :to => 'home#index'とされていました。

この解決策はhereにあります。

+3

ハッシュの代わりにスラッシュを使用する – Catfish

0

私のケースでは、それは私のルートのいくつかで接尾辞スラッシュ「/」によって引き起こされました。例えば。

post 'load_query/' 

post 'load_query' 

にこの接尾辞を除去した後、それが働きました。

8

これは誤ったルートによって引き起こされます。
config/routes.rbを確認してください。たとえ1つの経路が間違っていても、このエラーがスローされます。
はまたルートが

'/url/for/something' => 'controller#action' 

または

root :to => 'controller#action 
+0

これは解決策です。ありがとうございます。 同じエラーが発生している可能性があります。同じチュートリアルを進めています。 routes.rbで最後に変更されたrawをコメントアウトするだけで、どのルートがエラーを引き起こしているのかわかり、構文を修正します。 – YogiZoli

2

であることを確認してください私はまた、Rubyのnubyだとマイケル・ハートルによってRailsのチュートリアルでの作業中に同じエラーが発生しました。あなたが私のような人なら、実際に本を読んだり読んだりするだけで、本に書かれているすべてのコードを入力するだけかもしれません。すべてがステップバイステップではありません。ヘビケース対キャメルケースを実証にHARTLは

$ rails generate controller static_pages ... 
ここ

は、HARTLは単にむしろで行われたラクダの場合よりも、ヘビケースを用いStaticPagesコントローラを生成するための命令を対比しようとしている次のコードでボックスを示しリスト3.4。ドット "..."は、単にコマンド行の残りの命令を編集または切り捨てるだけです。

SampleApp::Application.routes.draw do 
get "static_pages/..." 

get "static_pages/home" 

get "static_pages/help" 

get "static_pages/..." 

routesファイルを保存し、再びレール・サーバを起動してみてくださいを削除し、あなたのルートファイルを開く:私は、ファイルが私のルートに以下に示されており、巻き取った正確に何で入力しました。

また、 "rails generate controller static_pages ..."を破壊しました。それが何らかの効果を持っているかどうかは分かりませんが、今はすべて動作します。

Rails.application.routes.draw do 
    get 'static_pages/...' 

    get 'static_pages/home' 

    get 'static_pages/help' 

はちょうどこのERASE:

1

デフォルトでは、これを取得

get 'static_pages/...' 

をAND YOUはroutes.rbをファイル

Rails.application.routes.draw do 

    get 'static_pages/home' 

    get 'static_pages/help' 
0

変更あなたのデフォルトのルートでこれを持つことになりますroutes.rbファイルに格納されます。

get "static_pages#home" TO root to: 'static_pages#home' 

私は同じ問題を抱えており、上記の変更が私のために働いています。

関連する問題