3
的Rails使其能夠映射在邏輯上其他資源的小孩在URL例如是否支持播放框架嵌套的路線如鐵軌?
/magazines/:magazine_id/ads/:id show display a specific ad belonging to a specific magazine
是否有可能做到這一點在遊戲資源?
的Rails使其能夠映射在邏輯上其他資源的小孩在URL例如是否支持播放框架嵌套的路線如鐵軌?
/magazines/:magazine_id/ads/:id show display a specific ad belonging to a specific magazine
是否有可能做到這一點在遊戲資源?
是的,那是可能的。它應該像這樣在你的路由文件:
GET /magazines/:magazine_id/ads/:id/show controllers.MyController.show(magazine_id: Long, id: Long)
而在你的控制器
public static Result show(Long magazine_id, Long id) {
...
}
玩不關心,如果參數代表某種關係,或不,這是你的控制器的工作。
當然也可以做到這一點:在
控制器GET /some/:parent/:child controllers.Application.getRelated(parent: Long, child: Long)
:
public static Result getRelated(Long parent, Long child) {
return ok(SomeFinder(parent,child));
}