title: flash not found in Products.scala
body: <p>I am currently reading 'Play for Scala' by Peter Hilton. I have just got the the end of the first example Play app where you build a paperclip directory.</p>
  
  <p>However upon compiling I get a compilation error telling me that the value 'flash' has not been found. Usually this is a simple mistake I have made but given that I am just following the guide in the book I can't identify a fix.</p>
  
  <p>The error is in lines 52 and 53 in the 'NewProduct' function</p>
  
  <p>Here is the code:</p>
  
  <pre><code>package controllers
  
  import play.api.mvc.{Action, Controller}
  import models.Product
  import play.api.data.Form
  import play.api.data.Forms.{mapping, longNumber, nonEmptyText}
  import play.api.i18n.Messages
  import play.api.mvc.Flash
  
  object Products extends Controller {
  
      private val productForm: Form[Product] = Form(
          mapping(
              "ean" -&gt; longNumber.verifying(
                  "validation.ean.duplicate", Product.findByEan(_).isEmpty),
              "name" -&gt; nonEmptyText,
              "description" -&gt; nonEmptyText
              )(Product.apply)(Product.unapply)
          )
  
      def list = Action {implicit request =&gt;
          val products = Product.findAll
  
          Ok(views.html.products.list(products))
      }
  
      def show(ean: Long) = Action {implicit request =&gt;
          Product.findByEan(ean).map {product =&gt;
              Ok(views.html.products.details(product))
          }.getOrElse(NotFound)
      }
  
      def save = Action { implicit request =&gt;
          val newProductForm = productForm.bindFromRequest()
  
          newProductForm.fold(
              hasErrors = {form =&gt;
                  Redirect(routes.Products.newProduct()).
                      flashing(Flash(form.data) + ("error" -&gt; Messages("validation.errors")))
              },
  
              success = {newProduct =&gt;
                  Product.add(newProduct)
                  val message = Messages("products.new.success", newProduct.name)
                  Redirect(routes.Products.show(newProduct.ean)).
                      flashing("success" -&gt; message)
              }
          )
      }
  
      def newProduct = Action { implicit request =&gt;
          val form = if(flash.get("error").isDefined)
              productForm.bind(flash.data)
          else
              productForm
  
          Ok(views.html.products.editProduct(form))
      }
  }
  </code></pre>