Added Nil check to show

This commit is contained in:
2016-04-22 12:22:33 -04:00
parent a8c353945d
commit a7ba05db29

View File

@@ -36,7 +36,12 @@ class VehiclesController < ApplicationController
# display a specific vehicle # display a specific vehicle
def show def show
@vehicle = Vehicle.find_by_id(params[:id]) @vehicle = Vehicle.find_by_id(params[:id])
if @vehicle
@customer = @vehicle.qbo_customer.name if @vehicle.qbo_customer @customer = @vehicle.qbo_customer.name if @vehicle.qbo_customer
else
flash[:error] = "Vehicle Not Found"
render :index
end
end end
# return an HTML form for editing a vehicle # return an HTML form for editing a vehicle