From 14cb22d743279fafcc8763b0ee96b764d65e51b0 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 4 Aug 2016 00:13:47 -0400 Subject: [PATCH] Update vehicles_controller.rb --- app/controllers/vehicles_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/vehicles_controller.rb b/app/controllers/vehicles_controller.rb index 0e47e93..63bd057 100644 --- a/app/controllers/vehicles_controller.rb +++ b/app/controllers/vehicles_controller.rb @@ -18,10 +18,12 @@ class VehiclesController < ApplicationController # display a list of all vehicles def index - begin - @vehicles = Customer.find_by_id(params[:customer_id]).vehicles.paginate(:page => params[:page]) - rescue ActiveRecord::RecordNotFound - render_404 + if params[:customer_id] + begin + @vehicles = Customer.find_by_id(params[:customer_id]).vehicles.paginate(:page => params[:page]) + rescue ActiveRecord::RecordNotFound + render_404 + end end if params[:search]