Play Framework. Routes. Error: "not enough arguments for method at..."

ses

There are my routes. Second one is commented.

GET         /assets/*file       controllers.Assets.at(path="/public", file)

#GET         /partials/*file    controllers.Assets.at(path="/public/partials", file)

( What I want is: to make my html files that are located inside "/public/partials" folder to be available through the web, same way as it's made for assets )

As soon as I uncomment 2nd line - it will get errors due to this line (from my index.scala.html):

<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">

Error is like here:

not enough arguments for method at: (path: String, file: String)play.api.mvc.Call. Unspecified value parameter file.

Q: What's wrong?

UPDATE:

Another words: I want to make my url shorter by providing that mapping. Otherwise I have to use this url: 'assets/partials/welcome.html' instead of that one (that I would like to use): 'partials/welcome.html'.

Just one more mapping that would make my urls shorter.

It make sense when I need to reach those from JS part, it's like having two applications in one (1.play one, 2. js one), there too routings, two roots. For JS one I'm assuming that I'm already in /public (or in assets) - this is a root for js app.

And I wonder why it doesn't work.

mantithetical

From the play docs:

Reverse routing for public assets

As for any controller mapped in the routes file, a reverse controller is created in controllers.routes.Assets. You use this to reverse the URL needed to fetch a public resource. For example, from a template:

<script src="@routes.Assets.at("javascripts/jquery.js")"></script>

This will produce the following result:

<script src="/assets/javascripts/jquery.js"></script>

Note that we don’t specify the first folder parameter when we reverse the route. This is because our routes file defines a single mapping for the Assets.at action, where the folder parameter is fixed. So it doesn’t need to be specified explicitly.

However, if you define two mappings for the Assets.at action, like this:

GET  /javascripts/*file        controllers.Assets.at(path="/public/javascripts", file)
GET  /images/*file             controllers.Assets.at(path="/public/images", file)

Then you will need to specify both parameters when using the reverse router:

<script src="@routes.Assets.at("/public/javascripts", "jquery.js")"></script>
<image src="@routes.Assets.at("/public/images", "logo.png")">

Any static html in the public/partials directory would be publicly available at /assets/partials/someHtml.html. So strictly speaking, you don't need the /partials/*file route

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Using POST routes parameters in Play Framework

From Dev

Long dynamic routes in play framework 2

From Dev

Non-capturing wildcards in Play Framework routes

From Dev

Play Framework, REST, Routes, and Controllers

From Dev

play framework - bind enum in routes

From Dev

split routes in multiple files for play framework 2.2

From Dev

Play framework - call controller in routes with Class parameter

From Dev

Play framework 2 : How to pass object between routes, views, and controller?

From Dev

Play framework routes, and scala predef values

From Dev

Error handling in play framework

From Dev

Play Framework 2.3.4 routes redirection to subproject

From Dev

Domain routes in Play Framework 2.3

From Dev

Build error in play framework

From Dev

Alternate constructor on Scala case class not defined: not enough arguments for method

From Dev

Iterating all Play Framework routes in Test

From Dev

Play Framework @routes.Assets.at Compilation Error

From Dev

Scala backticks in Play Framework Routes

From Dev

Finch: not enough arguments for method 'toService'

From Dev

Play Framework Error in Routes file

From Dev

Play Framework Inject Error

From Dev

Non-capturing wildcards in Play Framework routes

From Dev

Using POST routes parameters in Play Framework

From Dev

Play framework routes

From Dev

Play framework - call controller in routes with Class parameter

From Dev

How to "rewrite" urls or routes with Play Framework 2

From Dev

Play Framework 2.3.4 routes redirection to subproject

From Dev

Build error in play framework

From Dev

Play Framework Inject Error

From Dev

build.sbt ProjectRef : not enough arguments for method apply

Related Related

HotTag

Archive