Advertisement
vadipp

Slick+play example

Aug 7th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.40 KB | None | 0 0
  1.   def insert = DBAction { implicit rs =>
  2.     catForm.bindFromRequest.fold(
  3.     badForm =>
  4.       BadRequest(s"Form cannot be parsed, errors: ${badForm.errors}"),
  5.     cat =>
  6.       if (cats.filter(_.name === cat.name).exists.run) {
  7.           BadRequest(s"A cat named ${cat.name} already exists")
  8.       } else {
  9.         cats.insert(cat)
  10.         Redirect(routes.Application.index())
  11.       }
  12.     )
  13.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement