2011-06-26 10 views
0

を使用しようとしている:新しいアクションがここに私のルートがあるショー

equipment_index GET /equipment(.:format)   {:action=>"index", :controller=>"equipment"} 
      POST /equipment(.:format)   {:action=>"create", :controller=>"equipment"} 
new_equipment GET /equipment/new(.:format)  {:action=>"new", :controller=>"equipment"} 
edit_equipment GET /equipment/:id/edit(.:format) {:action=>"edit", :controller=>"equipment"} 
equipment GET /equipment/:id(.:format)  {:action=>"show", :controller=>"equipment"} 
      PUT /equipment/:id(.:format)  {:action=>"update", :controller=>"equipment"} 
      DELETE /equipment/:id(.:format)  {:action=>"destroy", :controller=>"equipment"} 
categories GET /categories(.:format)   {:action=>"index", :controller=>"categories"} 
      POST /categories(.:format)   {:action=>"create", :controller=>"categories"} 
new_category GET /categories/new(.:format)  {:action=>"new", :controller=>"categories"} 
edit_category GET /categories/:id/edit(.:format) {:action=>"edit", :controller=>"categories"} 
category GET /categories/:id(.:format)  {:action=>"show", :controller=>"categories"} 
      PUT /categories/:id(.:format)  {:action=>"update", :controller=>"categories"} 
      DELETE /categories/:id(.:format)  {:action=>"destroy", :controller=>"categories"} 

私は、私は次のエラーを取得するhttp://localhost:3000/equipment/newに行く:

No route matches {:action=>"show", :controller=>"equipment"} 

これは私のroutes.rbをファイルです:

Equipmentmanager::Application.routes.draw do 
    resources :equipment 
    resources :categories 
end 

nifty:scaffoldを使用したことを除いて、他のすべてはデフォルトに設定されています。

これは3.1ですが、3.0でも同じです 私には何が欠けているのですか?

+0

最初に述べた経路はどこにありますか? – Msencenb

答えて

0

だから、localhostを:3000 /機器/新しいが、この行にルーティングなっている:

equipment GET /equipment/:id(.:format) {:action=>"show", :controller=>"equipment"} 

それがあるべきとおり。実際に新しいルートに移動するには、そのルートを定義しているので、localhost:3000/new_equipmentを呼び出す必要があります。ビットクリーンな構文として

あなたはlocalhostを望んだ場合:新しいアクションにルーティングする3000/new_equipmentあなたは(リソース上:機器のラインをそのより具体的なので):あなたのroutes.rbをファイルに次の行を入れることができます

get "new_equipment" => "equipment#new", :as => "new_equipment" 

この行では、new_equipment_pathおよびnew_equipment_urlへのアクセスを提供するヘルパーも定義されます。

+0

これで何か不足していますか?それはそこのデフォルトルートです。レールがそれを処理できないようにすべきですか?私はカテゴリと呼ばれる別の骨格を持っており、それはそれのためのデフォルトのルートで見つけることができます。それは複数形が単数形と同じであるからですか?それが私が見ることができる唯一の違いです。 –

+0

あなたのルートはどのような順序で定義されていますか?リソース:他の経路の下にある機器ですか? – Msencenb

+0

この装置が唯一の装置だったのですが、この答えが出されたときにもう一方を追加しました。あなたの疑問に答えるには:今でも装置は一番上です –

関連する問題