2012-03-09 6 views
1

私は保険への追加措置として、「設定」を追加するには、このを持っている:名前空間の追加アクションをどのようにルーティングするのですか?私のroutes.rbをで

namespace :modules do 
    namespace :insurance do 
     resources :insurances do 
      member do 
       get :settings 
      end 
     end 
    end 
end 

「すくいルート」によると、これは次のパスを与える:

settings_modules_insurance_insurance_path 

しかし、私は、ブラウザでそのパスを訪問し、それがエラーを返します:

No route matches {:action=>"settings", :controller=>"modules/insurance/insurances"} 

これはすくいルートのフル出力に含まです:

settings_modules_insurance_insurance GET /modules/insurance/insurances/:id/settings(.:format) {:action=>"settings", :controller=>"modules/insurance/insurances"} 

どうすればよいですか?あなたが保険のIDを渡すために持っているので、あなたは、メンバーに新しいルートを入れている

+1

公式のレール文書では、2つ以上のレベルのリソースをネストしないことを実際にお勧めします。あなたのアプリはapp/controllers/modules/insurance/insurances_controller.rbのコントローラを探しているでしょう。 – Jon

+0

あなたはそうです、これは複雑すぎて、慣例を超えた設定になります。それはRailsのことではありません。これを指摘してくれてありがとう! – John

答えて

0

settings_modules_insurance_insurance_path(@insurance) 
+0

ありがとう、これは動作します。しかし、これはあまりにも複雑になるので、私は描画ボードに戻ります。 – John

0

コントローラの完全な名前は、右、モジュール::保険:: InsurancesControllerすべきですか?

関連する問題