[2.0] Reverse routes for subpackages of controllers?

345 views
Skip to first unread message

John Hicks

unread,
Jan 6, 2012, 8:54:32 PM1/6/12
to play-framework
While refactoring a small play 2.0 app, I moved some actions into
subpackages of controllers (controllers.postings) and added some
routes such as:

GET /postings/:id
controllers.postings.Jobs.show(id: Long)

This works fine, but controllers.routes only has ReverseRoutes for
classes in the main controllers package, not subpackages. Is there a
way to get this to work?

-John

Ben McCann

unread,
Jan 7, 2012, 2:07:34 AM1/7/12
to play-framework
The routes are generated, but you're looking in the wrong package.
Try looking in controllers.postings.routes.Jobs instead of
controllers.routes.postings.Jobs.

Hope this helps,
Ben

Julien Richard-Foy

unread,
Jan 7, 2012, 4:02:13 AM1/7/12
to play-fr...@googlegroups.com
I dont understand this convention. IMHO, routes should be generated in a root package "routes", then in a sub package with the same name as the controller package.

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>

Ben McCann

unread,
Jan 7, 2012, 1:59:44 PM1/7/12
to play-framework
I agree Julien. The current packages seem backwards and non-intuitive
to me. Clearly John ran into this issue as well.


On Jan 7, 1:02 am, Julien Richard-Foy <j...@zenexity.com> wrote:
> I dont understand this convention. IMHO, routes should be generated in a root package "routes", then in a sub package with the same name as the controller package.
>

John Hicks

unread,
Jan 7, 2012, 2:16:08 PM1/7/12
to play-framework
This works, thanks Ben. Was in a hurry last night.
Reply all
Reply to author
Forward
0 new messages