2
我使用的轨道路由的一员,我想有一些像添加浅资源作为另一个资源
resources :user
member do
resources :comments, shallow: true
end
end
# To get the following routes
get /users/:id/comments (index)
post /users/:id/comments (create)
get /comments/:id (show)
put /comments/:id (update)
delete /comments/:id (destroy)
然而变浅不工作,我有以下途径(不提的是,:id
用户和评论是相互矛盾的)
get /users/:id/comments
post /users/:id/comments
get /users/:id/comments/:id
put /users/:id/comments/:id
delete /users/:id/comments/:id
我知道,平时做的推荐方法是
resources :user
resources :comments, shallow: true
end
# To get the following routes
get /users/:user_id/comments
post /users/:user_id/comments
get /comments/:id
put /comments/:id
delete /comments/:id
但我想要:id
在params
而不是:user_id
浅层路由创建/索引。 This is usually done by using member
你可以离开了:上选项,这将创建不同的是值的资源ID将在 PARAMS提供相同的成员 路线[:photo_id]代替PARAMS [:ID]。
有没有人知道为什么在member
指令内完成浅化后不能正常工作?