Fixed filter_vehicles_by_customer method

This commit is contained in:
2017-03-22 21:55:07 -04:00
committed by GitHub
parent 48b6df0cef
commit 8af97072fb

View File

@@ -34,10 +34,8 @@ class CustomersController < ApplicationController
autocomplete :customer, :name, :full => false, :extra_data => [:id] autocomplete :customer, :name, :full => false, :extra_data => [:id]
def autocomplete_customer_vehicles def filter_vehicles_by_customer
customer = Customer.find_by_id(params[:term]) @filtered_vehicles = Vehicle.all.where(customer_id: params[:selected_customer])
items = customer.vehicles if customer
render :json => items.to_json if items
end end
# display a list of all customers # display a list of all customers
@@ -144,10 +142,6 @@ class CustomersController < ApplicationController
end end
end end
def filter_vehicles_by_customer
@filtered_vehicles = Customer.find(customer_id: params[:selected_customer]).vehicles
end
private private
def only_one_non_zero?( array ) def only_one_non_zero?( array )