1

データベースに非常に単純なタイプのレコード(「client_types」)を追加しようとしている単純なレールアプリケーションがあります。ルーティングリソースが "new"を期待通りに処理しない

私は読みroutes.rbでのルートがあります。

resources :client_types

そして、私はそれを理解するように、私のclient_typesリソースのための従来の経路の全てにプロキシする必要があります。

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

お知らせ問題のアクションが、ここで、新しいものではないショーです(と私はメソッドのを持っている:私は、次のURL http://localhost:3000/client_types/newを参照するとき

だから、私は、実行時に次のルーティングエラーが発生します私のコントローラではこれらの両方)。

だから... ...私は、上記のリソースのルートの下に次のルートを追加し、ヴィオラ、それが動作します:

match 'client_types/new' => 'client_types#new', :as => :client_type

だから私は何をしないのですか?私の前提は、私​​のルーティングファイル内のresources :client_typesが、明示的に後で追加したものと一致するルートを追加したということでした。

rake routesは、次のことを明らかに:

client_types  GET /client_types(.:format)   {:action=>"index", :controller=>"client_types"} 
       POST /client_types(.:format)   {:action=>"create", :controller=>"client_types"} 
new_client_type GET /client_types/new(.:format)  {:action=>"new", :controller=>"client_types"} 
edit_client_type GET /client_types/:id/edit(.:format) {:action=>"edit", :controller=>"client_types"} 
client_type  GET /client_types/:id(.:format)  {:action=>"show", :controller=>"client_types"} 
       PUT /client_types/:id(.:format)  {:action=>"update", :controller=>"client_types"} 
       DELETE /client_types/:id(.:format)  {:action=>"destroy", :controller=>"client_types"} 
client_type   /client_types/new(.:format)  {:controller=>"client_types", :action=>"new"} 
+3

「レーキルート」をご覧になり、あなたが見たものを報告してください。 –

+0

「私が着陸するとき」 - あなたがどのように "着陸"しているか説明してください。 URLまたはリンクから –

+0

「私が着陸するとき」とはブラウザのURLを意味します。 – jn29098

答えて

0

これが今取り組んでいます。私は私の意見の1つに問題がありました。このエラーメッセージは赤いニシンでした。

関連する問題