Rails路由。具有成员操作的多个嵌套路由

时间:2013-09-11 20:00:21

标签: ruby-on-rails nested-resources

我有以下路线:

resources :projects do
    resources :milestones, :comments
end

resources :comments do
    member {post :hide}
end 

我希望能够写出类似的内容:

resources :projects do
    resources :milestones, 
    resources :comments do 
        member {post :hide}
    end
end

但这会引发错误。

我搜索过互联网,但似乎无法找到我的问题。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

删除资源之间的逗号:里程碑和资源:评论。你的代码应该是

    resources :projects do
        resources :milestones 
        resources :comments do 
            member {post :hide}
        end
    end