Railsを使用すると、他のリソースの論理的な子であるリソースをURLにマッピングできます。
/magazines/:magazine_id/ads/:id show display a specific ad belonging to a specific magazine
In Playでこれを行うことは可能ですか?
Railsを使用すると、他のリソースの論理的な子であるリソースをURLにマッピングできます。
/magazines/:magazine_id/ads/:id show display a specific ad belonging to a specific magazine
In Playでこれを行うことは可能ですか?
Playは、引数が何らかの関係を表すかどうかを気にしません。それはコントローラーの仕事です。
もちろん、それを行うことは可能です:
GET /some/:parent/:child controllers.Application.getRelated(parent: Long, child: Long)
コントローラー内:
public static Result getRelated(Long parent, Long child) {
return ok(SomeFinder(parent,child));
}
はい、それは可能です。ルートファイルでは次のようになります。
GET /magazines/:magazine_id/ads/:id/show controllers.MyController.show(magazine_id: Long, id: Long)
そしてあなたのコントローラーで
public static Result show(Long magazine_id, Long id) {
...
}