1
votes

I have based the app on a couple of the sample apps but im getting the error: could not find implicit value for parameter flash: play.api.mvc.Flash

(i want the flash to satify the templates @(title: String, user: User, systems: List[System], currentOrderBy: Int, currentFilter: String)(implicit flash: play.api.mvc.Flash) signature so I can pass the prior results in)

this is my code that give the issue:

def index = IsAuthenticated { username => _ => 
    User.findByEmail(username).map { user =>
      Ok(
        html.systems.systems("Ken2::Systems",
          user,
          System.all,
          1, "%"
        )
      )
    }.getOrElse(Forbidden)
  }

in the documentationn it says : If the error ‘could not find implicit value for parameter flash: play.api.mvc.Flash’ is raised then this is because your Action didn’t import a request object. Add an “implicit request=>” as show below:

def index() = Action {   
  implicit request =>
    Ok(views.html.Application.index())
}

but where in my code would i stick this implicit request ? (the format of my code comes from one of the sample apps)

thank you

1

1 Answers

4
votes

You have masked the implicit request with the _ wildcard. As far as I understand Scala, when you use the wildcard, it means, ignore this whatever it is. Meaning, you cannot use it further in your code. But the flash scope needs access to the request, that's why it isn't working.

This should work :

def index = IsAuthenticated { username => implicit request => 
    ...
}