From a70561b5bde549f6134b1c1feec0a98e3523bef3 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Fri, 6 May 2016 12:25:30 -0400 Subject: [PATCH] Update vehicles_controller.rb --- app/controllers/vehicles_controller.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/vehicles_controller.rb b/app/controllers/vehicles_controller.rb index 72d8c28..e9fbdc6 100644 --- a/app/controllers/vehicles_controller.rb +++ b/app/controllers/vehicles_controller.rb @@ -36,10 +36,10 @@ class VehiclesController < ApplicationController flash[:notice] = "New Vehicle Created" redirect_to @vehicle else - @customers = Customer.all.order(:name) - render :edit + flash[:error] = @vehicle.errors.full_messages.to_sentence + redirect_to :new end - flash[:error] = @vehicle.errors.full_messages.to_sentence if @vehicle.errors + end # display a specific vehicle @@ -49,8 +49,7 @@ class VehiclesController < ApplicationController @customer = @vehicle.customer.name if @vehicle.customer else flash[:error] = "Vehicle Not Found" - @customers = Customer.all.order(:name) - render :index + redirect_to :index end end @@ -63,14 +62,13 @@ class VehiclesController < ApplicationController # update a specific vehicle def update - @customers = Customer.all.order(:name) @customer = params[:customer] @vehicle = Vehicle.find_by_id(params[:id]) if @vehicle.update_attributes(params[:vehicle]) flash[:notice] = "Vehicle updated" redirect_to @vehicle else - render :edit + redirect_to :edit end flash[:error] = @vehicle.errors.full_messages.to_sentence if @vehicle.errors end