轨,path_names和嵌套资源
问题描述:
我的路线:轨,path_names和嵌套资源
resources :events, :path_names => { :new => "organize" } do
resources :forums
end
通过这些途径,我会得到类似的url /events/:event_id/forums/organize
。我不希望path_names传播到我的嵌套路由...我是否必须重新定义path_names
他们?或者使用scope
?
resources :events, :path_names => { :new => "organize" } do
scope :path_names => { :new => "new" } do
resources :forums
# other nested resources...
end
end
(我的最爱,直到你找到一个更好的解决方案;))
resources :events, :path_names => { :new => "organize" }
resources :events, :only => [] do
#nested resources...
end
有没有更优雅的方式来做到这一点?如果你不这么认为,你也可以告诉我哪一个是你认为最好的。
答
我去的最后一个选项:
resources :events, :path_names => { :new => "organize" }
resources :events, :only => [] do
#nested resources...
end
怎么样定义':以同样的方式为path_names'论坛? – 2012-01-04 03:18:58
这是一个选项,但不是我认为的最好的选项。因为我有很多嵌套的资源,而不仅仅是论坛。所以最坏的情况下,我会使用其他两种解决方案。 – Robin 2012-01-04 03:22:59