scala - Too many arguments in Play2 template -
i have simple application in process of building, , running complication error cannot determine why. (full disclosure: first scala/play project)
the error reads:
too many arguments method apply: ()play.api.templates.html in object dailychart
there 1 argument view can surmise list of glucosereadings. controller passing list of glucosereadings provided model @ lost why there too many arguments when number of arguments , types match.
i have simple model, controller , view display simple chart of glucose readings day.
the model follows (in file glucosereadings.scala):
package models import play.api.db._ import play.api.play.current import anorm._ import anorm.sqlparser._ import org.joda.time._ import java.util.date case class glucosereading( id: int, mgdl: int, recordtime: datetime ) object glucosereading { val glucosereading = { get[int]("id") ~ get[int]("mgdl") ~ get[date]("recordtime") map { case id~mgdl~recordtime => glucosereading(id, mgdl, new datetime(recordtime)) } } def dailyreadings(date: datetime): list[glucosereading] = { db.withconnection { implicit connection => sql(""" select id, recordtime, mgdl glucosereading order recorddate desc """).as(glucosereading *) } } } the controller (in file glucosereadingscontroller.scala):
package controllers import play.api.mvc._ import play.api.data._ import play.api.data.forms._ import org.joda.time._ import models.glucosereading object glucosereadingscontroller extends controller { def daily(year: int, month: int, day: int) = action { val date = new datetime(year, month, day,0,0) val readings = glucosereading.dailyreadings(date) ok(views.html.dailychart(readings)) } } and view (in file dailychart.scala.html):
@(readings: list[glucosereading]) @import helper._ @main("day read") { <ul> @reading.map { reading => <li> i'm glucose reading </li> } </ul> } based on comments main template below
@(title: string)(content: html) <!doctype html> <html> <head> <title>@title</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="css/bootstrap.min.css" rel="stylesheet" media="screen"> </head> <body> @content <script src="http://code.jquery.com/jquery.js"></script> <script src="js/bootstrap.min.js"></script> </body> </html>
the problem can see is:
<ul> @reading.map { reading => <li> it should compile fine 1 change @readings.map. if not, exit play , remove target directory, try again.
Comments
Post a Comment