2011-06-29 14 views
0

専用のadmin/countries_controllerは、レコード作成以外のすべてのアクション(index、...)に対して正しく使用されています。ここでは、親コントローラディレクトリから定期countries_controllerはアクティブです:ルーティングレール管理コントローラ作成アクション

Started POST "/countries" for 127.0.0.1 at 2011-06-29 23:26:38 +0200 
    Processing by CountriesController#create as HTML 

管理者/国にルーティングされているPOSTの作用を有することが欠けていますか?

routes.rbを:

resources :countries 

    namespace :admin do 
    resources :countries 
    end 

すくい路線:ここに未回答

 countries GET /countries(.:format)    {:action=>"index", :controller=>"countries"} 
       POST /countries(.:format)    {:action=>"create", :controller=>"countries"} 
    new_country GET /countries/new(.:format)   {:action=>"new", :controller=>"countries"} 

    admin_countries GET /admin/countries(.:format)   {:action=>"index", :controller=>"admin/countries"} 
        POST /admin/countries(.:format)   {:action=>"create", :controller=>"admin/countries"} 
new_admin_country GET /admin/countries/new(.:format)  {:action=>"new", :controller=>"admin/countries"} 

同様の質問:あまりにも名前空間べき Rails help with building Admin area - Routing problem

+0

あなたのビューでPOSTリクエストを開始するURLをどのように構築していますか? – drummondj

+0

'<%= link_to 'New country'、new_admin_country_path%>'は、<%= form_for(@country)do | f |を含む標準的な足場フォームヘルパーにつながります。 %> 'と' <%= f.submit%> ' – David

答えて

1

あなたform_forニーズ:

<%= form_for [:admin, @country] do |f| %> 
    ... 
<% end %> 

あなたはあなたがこのフォームはに行きたいものの名前空間を知っているつもりはないので、それだけで標準POST /countries URLがデフォルトになります@countryform_forに渡し 。

+0

本当にありがとう、ライアン! – David

関連する問題