Ahmed Aswani
Ahmed Aswani

Reputation: 8649

Does play framework support Nested routes like rails?

Rails make It possible to map resources that are logically children of other resources In the URL for example

/magazines/:magazine_id/ads/:id show    display a specific ad belonging to a specific magazine

Is it possible to do this In Play?

Upvotes: 3

Views: 924

Answers (2)

aaberg
aaberg

Reputation: 2273

Yes, that is possible. It should look like this in your routes file:

GET   /magazines/:magazine_id/ads/:id/show   controllers.MyController.show(magazine_id: Long, id: Long)  

And in your controller

public static Result show(Long magazine_id, Long id) {
    ...
}

Upvotes: 2

biesior
biesior

Reputation: 55798

Play doesn't care if arguments represents some kind of relation or not, it's job for your controller.

Of course it is possible to do that:

GET /some/:parent/:child   controllers.Application.getRelated(parent: Long, child: Long)

in controller:

public static Result getRelated(Long parent, Long child) {
    return ok(SomeFinder(parent,child));
}

Upvotes: 7

Related Questions