From 4dfbdbfdda5c3e8037f4cb5cef1c6d991fc43a9a Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Sun, 29 May 2016 11:17:38 -0400 Subject: [PATCH] Update customer.rb --- app/models/customer.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/customer.rb b/app/models/customer.rb index f52c562..699100e 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -19,7 +19,6 @@ class Customer < ActiveRecord::Base validates_presence_of :id, :name - self.primary_key = :id # returns a human readable string @@ -108,9 +107,12 @@ class Customer < ActiveRecord::Base query = "Select Id, DisplayName From Customer" query << " Where Metadata.LastUpdatedTime >= '#{last.iso8601}' " if last - customers = service.query(query) - customers = service.all if count == 0 - + if count == 0 + customers = service.all + else + customers = service.query(query) + end + customers.each do |customer| qbo_customer = Customer.find_or_create_by(id: customer.id) qbo_customer.name = customer.display_name