0

This code compiles but the Environment.insert is never called. I'm sure there is an envrionmentForm there.

//isauth version of save
  def save(SystemId: Long) = IsAuthenticated { username => implicit request =>
    User.findByEmail(username).map { user => 
      System.findById(SystemId).map { system => 

      environmentForm.bindFromRequest.fold(
      formWithErrors => BadRequest(html.env_views.createForm(formWithErrors, system, Person.options, user)),
      env => {
        Environment.insert(env)
        Application.Home.flashing("success" -> "Environment %s has been created".format(env.env_name))
      }
    )
    }.getOrElse(Forbidden)
    }.getOrElse(Forbidden)
  }
Shiva
  • 20,575
  • 14
  • 82
  • 112
mbrambley
  • 245
  • 3
  • 10
  • 1
    You may debug to see variables(or println), and you can rewrite use for-comprehension ```for { u <- User.findXXX; s <- System.findXXX } yield {} ``` – jilen Feb 14 '14 at 02:17
  • but i want to know whats in environmentForm and therefore why Environment.insert is never called – mbrambley Feb 14 '14 at 11:04
  • can you post your `environmentForm`'s code? – Peter Feb 14 '14 at 14:28
  • I'd try to use a debugger or simply add logging (play.api.Play.Logger) to see whether you do get a form that has no errors, and then also logging inside Envrionment.insert. Its possible that whatever insert is doing has a silent error inside, but I can't give a good answer without knowing more about the code. – Jason Pearson Feb 14 '14 at 17:33

0 Answers0