rails routing: nested resources with different namespace

偶尔善良 提交于 2019-12-08 03:31:20

问题


I am trying to use the acts_as_commentable GEM to add comments to my Post Model. I am using ABC as namespace, so all my controller and models named as ABC::Post, ABC::User, etc.

Currently my routing setup is as following.

namespace :abc do
  resources :post do 
    resources :comments
  end
end

The routing URL generated is

POST   /abc/post/:id/comments(.:format)          abc/comments#create

How can i make it to

POST   /abc/post/:id/comments(.:format)         /comments#create

回答1:


founded the answer

namespace :abc do
    resources :post do 
        resources :comments, controller: '/comments'
  end
end


来源:https://stackoverflow.com/questions/26923538/rails-routing-nested-resources-with-different-namespace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!