scala - missing arguments for method apply... Play Framework 2.4 compilation error -


compilation error: missing arguments method apply in class newpost; follow method `_' if want treat partially applied function

i don't understand how template handling methods have , complier require of me.
https://github.com/flatlizard/blog

controller:

  def addpost = action{ implicit request =>     ok(views.html.newpost(postform))   }    def createpost = action { implicit request =>     postform.bindfromrequest.fold(       haserrors => badrequest,       success => {         post.create(post(new date, success.title, success.content))         ok(views.html.archive("my blog", post.all))       })   } 

routes:

get        /archive/new         controllers.application.addpost  post       /archive             controllers.application.createpost

view:

@(postform: form[post])(content: html)(implicit messages: messages) @import helper._  @form(routes.application.createpost) {     @inputdate(postform("date"))     @textarea(postform("title"))     @textarea(postform("content"))     <button id="submit" type="submit" value="submit" class="btn btn-primary">submit</button> } 

update

i solved problem adding following imports in controller file:

import play.api.i18n.messages.implicits._ import play.api.play.current 

see play 2.4 migration: https://www.playframework.com/documentation/2.4.x/migration24#i18n

compilation error

your view expects 3 parameters passed, passing one. solve compilation error, change signature in view from@(postform: form[post])(content: html)(implicit messages: messages) @(postform: form[post])(implicit messages: messages).

parameters , views

the second parameter in example (content: html) used when combine several views:

index.scala.html

@(text: string)  @main("fancy title") {   <div>@text</div> } 

main.scala.html

@(title: string)(content: html)  <html>   <head>     <title>@title</title>   </head>   <body>     @content   <body> </html> 

call in controller

ok(views.html.index("some text")) 

in example passing "some text" index view. index view calls main view passing 2 parameters. title , content, content html in between curly braces of index.scala.html (<div>@text</div>)

finally implicit parameters: (implicit messages: messages) must somewhere in scope passed implicitly view. example in controller:

def addpost = action{ implicit request =>    implicit val messages: messages = ...    ok(views.html.newpost(postform)) } 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -