2011-08-28 10 views
5

すべてのコーディング世界に新しく、RoRを初めて使用しました。私はチュートリアルをしていて、昨夜いくつかの問題に遭遇しました。私の友人はそれらのうちのいくつかを助けました。私はここでいくつか尋ねた。それでも、これは私を困惑させる。私はそれの問題を見つけることができません。"/ index"と一致するルートはありません。簡単な問題?

ページが読み込まれ、表示する必要がある内容が表示されます。私はそこにリンクを押すと、しかし、それはこの中で結果:

Routing Error 

No route matches "/index" 

は、だから私は rake routesを行なったし、私はこれは私のroutes.rbを

root :to => "Site#index" 
get "site/index"  
get "site/about" 
get "site/help" 

Iである。この

Dennis-Buizerts-MacBook-Pro:gpoff dennisbuizert$ rake routes 
site_index GET /site/index(.:format) {:controller=>"site", :action=>"index"} 
site_about GET /site/about(.:format) {:controller=>"site", :action=>"about"} 
site_help GET /site/help(.:format) {:controller=>"site", :action=>"help"} 
     root  /(.:format)   {:controller=>"Site", :action=>"index"} 

を得ましたmap.connectsmatchを追加しようとしましたが、それは解決していないようです。 そして、私のdevelopment.logがフォローを言う:// webdevrefinery:誰も返事をポストしない場合

Started GET "/" for 127.0.0.1 at 2011-08-28 10:05:51 +0200 
DEPRECATION WARNING: Disabling sessions for a single controller has been deprecated. Sessions are now lazy loaded. So if you don't access them, consider them off. You can still modify the session cookie options with request.session_options. (called from <class:ApplicationController> at /Users/dennisbuizert/Sites/gpoff/app/controllers/application_controller.rb:3) 
    Processing by SiteController#index as HTML 
Rendered site/index.html.erb within layouts/application (1.6ms) 
Completed 200 OK in 5ms (Views: 4.3ms | ActiveRecord: 0.0ms) 


Started GET "/index" for 127.0.0.1 at 2011-08-28 10:05:52 +0200 

ActionController::RoutingError (No route matches "/index"): 


Rendered /Users/dennisbuizert/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.8ms) 
+0

get 'index' => "site#index" 

を試してみてください、あなたは、[HTTPを試してみてください。 com /](http://webdevrefinery.com/)。奇妙な時間にそこにぶら下がっているRoRのacolytesの束があります。 –

+0

ありがとう、私はそれを念頭に置いておきます。 – dbuizert

+0

'/ index'へのこのリンクはどのように作られていますか?なぜなら、ルートは '/ index'ではなく、単に'/'でなければならないからです。 – nathanvda

答えて

4

ではなく

get "site/index" 
+0

ありがとうございます。これで修正されました。これは回避策ですか?または、これは後で、これが良い解決策であることを発見するでしょうか? – dbuizert

+0

@dbuizert、Imm、これは回避策かもしれませんが、ルートを変更しない場合は、ビューまたはレイアウトファイルの '/ index'の代わりに'/site/index'または '/'へのリンクを変更する必要があります。 – YOU

+0

実際には、率直に言って、 '/ index'にはまったく到達すべきではありません。 '/'だけで十分です。この解決策は実際には '/ index'とタイプすることができるようにしますが、通常は決して必要ではありません。 – nathanvda

関連する問題