【问题标题】:rails routing: nested resources with different namespacerails routing:具有不同命名空间的嵌套资源
【发布时间】:2014-11-14 05:31:04
【问题描述】:

我正在尝试使用 acts_as_commentable GEM 将 cmets 添加到我的帖子模型中。我使用 ABC 作为命名空间,所以我所有的控制器和模型都命名为 ABC::Post、ABC::User 等。

目前我的路由设置如下。

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

生成的路由URL是

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

我怎样才能做到

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

【问题讨论】:

    标签: ruby-on-rails acts-as-commentable


    【解决方案1】:

    找到答案

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

    【讨论】:

      猜你喜欢
      • 2012-10-02
      • 1970-01-01
      • 2011-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-14
      • 2021-09-20
      • 2023-03-11
      相关资源
      最近更新 更多