/**
  * Validates data submitted in the edit form. If the validation fails,
  * displays the edit page. Otherwise, updates the information in the 
  * database and redirects back to the edit page.
  *  
  * @param int $id id of the edited ingredient
  */
 public static function edit($id)
 {
     $params = $_POST;
     $attributes = array('id' => $id, 'ingredient_name' => $params['ingredient_name'], 'ingredient_type' => $params['ingredient_type'], 'price' => $params['price']);
     $validator = self::ingredient_validator($attributes);
     if ($validator->validate()) {
         $ingredient = new Ingredient($attributes);
         $ingredient->update();
         Redirect::to($params['redirect'], array('message' => 'Ainesosaa muokattu!'));
     } else {
         View::make('ingredient/edit.html', array('errors' => $validator->errors(), 'ingredient' => $attributes));
     }
 }