2012-03-09 90 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"} 

我该怎么办?

+1

官方rails文档实际上建议您不要将资源嵌套深度超过一个等级。你的应用程序将在应用程序/控制器/模块/保险/ insurances_controller.rb – Jon 2012-03-09 08:27:05

+0

寻找一个控制器你是对的,这变得太复杂,并成为配置超过约定,这不是什么Rails是关于。感谢您指出了这一点! – John 2012-03-09 10:09:16

回答

0

你穿上成员的新途径,所以你必须通过保险ID:

settings_modules_insurance_insurance_path(@insurance) 
+0

谢谢,这个工程。不过,我要回到绘图板,因为这太复杂了。 – John 2012-03-09 10:09:42

0

控制器应模块::保险:: InsurancesController的全名,对不对?

相关问题