0
如果我设置路由类似下面,它创建路径自动比如 community_community_topic, new_community_community_topic, edit_community_community_topic是否可以一次自定义路由路径?
resources :communities, :path => "community" do
resources :community_topics, :path => "topic"
end
,如果我想要什么这样
community_topic替代路径的community_community_topics
我该如何编码我的routes.rb?
通常,您可以显着地消除这些助手的使用情况。检查** [polymorphic_url](http://api.rubyonrails.org/classes/ActionDispatch/Routing/PolymorphicRoutes.html#method-i-polymorphic_url)**以了解可能性。其他助手,如'link_to'正在通过这种方法运行他们的选项。所以你可以写下:link_to'View',[@community,@topic]'或'link_to'New',[:new,@community,:community_topic]'这些都很清楚,不需要修改你的路由。 – jdoe