From 8af97072fb175fa7234db0d90af6245624596cb6 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Wed, 22 Mar 2017 21:55:07 -0400 Subject: [PATCH] Fixed filter_vehicles_by_customer method --- app/controllers/customers_controller.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/controllers/customers_controller.rb b/app/controllers/customers_controller.rb index 7d9389d..409b8b2 100644 --- a/app/controllers/customers_controller.rb +++ b/app/controllers/customers_controller.rb @@ -34,10 +34,8 @@ class CustomersController < ApplicationController autocomplete :customer, :name, :full => false, :extra_data => [:id] - def autocomplete_customer_vehicles - customer = Customer.find_by_id(params[:term]) - items = customer.vehicles if customer - render :json => items.to_json if items + def filter_vehicles_by_customer + @filtered_vehicles = Vehicle.all.where(customer_id: params[:selected_customer]) end # display a list of all customers @@ -144,10 +142,6 @@ class CustomersController < ApplicationController end end - def filter_vehicles_by_customer - @filtered_vehicles = Customer.find(customer_id: params[:selected_customer]).vehicles - end - private def only_one_non_zero?( array )