[英]rails routing: nested resources with different namespace
I am trying to use the acts_as_commentable GEM to add comments to my Post Model. 我正在尝试使用acts_as_commentable GEM向我的帖子模型添加评论。 I am using ABC as namespace, so all my controller and models named as ABC::Post, ABC::User, etc. 我使用ABC作为名称空间,所以我所有的控制器和模型都命名为ABC :: Post,ABC :: User等。
Currently my routing setup is as following. 目前,我的路由设置如下。
namespace :abc do
resources :post do
resources :comments
end
end
The routing URL generated is 生成的路由URL是
POST /abc/post/:id/comments(.:format) abc/comments#create
How can i make it to 我该怎么做
POST /abc/post/:id/comments(.:format) /comments#create
founded the answer 建立了答案
namespace :abc do
resources :post do
resources :comments, controller: '/comments'
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.