データベースに非常に単純なタイプのレコード(「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"}
「レーキルート」をご覧になり、あなたが見たものを報告してください。 –
「私が着陸するとき」 - あなたがどのように "着陸"しているか説明してください。 URLまたはリンクから –
「私が着陸するとき」とはブラウザのURLを意味します。 – jn29098