Crayl
Crayl

Reputation: 1911

How to call routes in subprojects in Play?

As I read this question occurs quite often, but I don't get it. So sorry for my noobishness.

Got a subproject called "subproject1"

In conf/routes I call it with -> /subproject1/ subproject1.Routes

In subproject1.Routes there is an action like:

GET   /admin/rater   subproject1.controllers.Application.rater(id: Int ?= 0)

There is a view like stuff.scala.html and a link like:

<a href='@vvv.controllers.routes.Application.rater()[email protected]()'>asdf</a>

Play says value Application is not a member of object vvv.controllers.routes, But the action is defined in Class "Application"

The route should be like vvv.controllers.vvv.routes.Application.rater().. but that's also an error.

Any suggestions are highly appreciated!

Upvotes: 1

Views: 259

Answers (1)

josephpconley
josephpconley

Reputation: 1723

An explanation for subprojects can be found here.

Per your example, you should define the routes in your subproject as

GET    /admin/rate    controllers.subproject1.Application.rater(id: Int ?= 0)

Then in the view you would call the route as follows (assuming you pass an id variable to the template):

<a href='@controllers.subproject1.routes.Application.rater(id)'>asdf</a>

Upvotes: 1

Related Questions