Hello everybody,
I'm in trouble with action composition,
I had the following method in an administration controller
def Authenticated(f: (User, Request[AnyContent]) => Result) = {
Action {
request =>
request.session.get("email").flatMap(u => User.findByEmail(u)).map {
user =>
f(user, request)
}.getOrElse(Unauthorized("401 - unautoriezd"))
}
}
when i use it in a method without form submission it's ok :
def create = Authenticated {
(user, request) =>
Ok(views.html.administration.create(postForm))
}
But when i use it in a method with bindFromRequest :
def save = Authenticated {
(user, request) =>
postForm.bindFromRequest.fold(
formWithErrors => BadRequest(views.html.administration.create(formWithErrors)),
post => {
Post.create(post)
Redirect(routes.Administration.index())
}
)
}
I have the following errors.
Cannot find any HTTP Request here
In /Users/damiengouyette/developpement/sources/play/plogengine-scala/app/controllers/Administration.scala at line 70.
66
67
68 def save = Authenticated {
69 (user, request) =>
70 postForm.bindFromRequest.fold(
71 formWithErrors => BadRequest(views.html.administration.create(formWithErrors)),
72 post => {
73 Post.create(post)
74 Redirect(routes.Administration.index())
Any ideas ?