From 336d1c7c7b47740d8daa531f4e935f5718d01299 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Mon, 1 Aug 2016 19:05:49 -0400 Subject: [PATCH] Update vehicles_controller.rb --- 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 44e071c..2d30531 100644 --- a/app/controllers/vehicles_controller.rb +++ b/app/controllers/vehicles_controller.rb @@ -18,7 +18,12 @@ class VehiclesController < ApplicationController # display a list of all vehicles def index - @vehicles = Vehicle.paginate(:page => params[:page]) + if params[:search] + @vehicles = Customer.search(params[:search]).paginate(:page => params[:page]) + if only_one_non_zero?(@vehicles) + redirect_to @vehicles.first + end + end end # return an HTML form for creating a new vehicle