From a7ba05db29807d40ef05a2dc86d079caa2923a24 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Fri, 22 Apr 2016 12:22:33 -0400 Subject: [PATCH] Added Nil check to show --- app/controllers/vehicles_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/vehicles_controller.rb b/app/controllers/vehicles_controller.rb index aeec54d..b3e98b4 100644 --- a/app/controllers/vehicles_controller.rb +++ b/app/controllers/vehicles_controller.rb @@ -36,7 +36,12 @@ class VehiclesController < ApplicationController # display a specific vehicle def show @vehicle = Vehicle.find_by_id(params[:id]) - @customer = @vehicle.qbo_customer.name if @vehicle.qbo_customer + if @vehicle + @customer = @vehicle.qbo_customer.name if @vehicle.qbo_customer + else + flash[:error] = "Vehicle Not Found" + render :index + end end # return an HTML form for editing a vehicle