From 33db0a53ba2d03bfefdff750f19b24392ec45c2d Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Fri, 5 Aug 2016 08:46:48 -0400 Subject: [PATCH] Update customer.rb --- app/models/customer.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/customer.rb b/app/models/customer.rb index b3e1e0e..dd5f0fb 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -142,18 +142,18 @@ class Customer < ActiveRecord::Base # Searchs the database for a customer by name def self.search(search) - customers = where("name LIKE ?", "%#{search}%").order(:name) + customers = where("name LIKE ?", "%#{search}%") if customers.empty? service = Qbo.get_base(:customer).service - results = service.query("Select Id From Customer Where ((PrimaryPhone LIKE '%#{search}%') OR (Mobile LIKE '%#{search}%') Order By DisplayName") + results = service.query("Select Id From Customer Where PrimaryPhone LIKE '%#{search}%' OR Mobile LIKE '%#{search}%'") results.each do |customer| customers << Customer.find_by_id(customer.id) end end - return customers + return customers.order(:name) end # proforms a bruteforce sync operation