From 3e0b327ea7088ecc81e4eac05821a5c7adf4efc6 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Tue, 24 May 2016 12:33:19 -0400 Subject: [PATCH] Update customer.rb --- app/models/customer.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/models/customer.rb b/app/models/customer.rb index a1ec2d6..385dd7f 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -109,12 +109,10 @@ class Customer < ActiveRecord::Base query << " Where Metadata.LastUpdatedTime >= '#{last.iso8601}' " if last Qbo.get_base(:customer).service.query(query).each do |customer| - Customer.transaction do - qbo_customer = Customer.find_or_create_by(id: customer.id) - qbo_customer.name = customer.display_name - qbo_customer.id = customer.id - qbo_customer.save_without_push - end + qbo_customer = Customer.find_or_create_by(id: customer.id) + qbo_customer.name = customer.display_name + qbo_customer.id = customer.id + qbo_customer.save_without_push end # remove deleted customers @@ -128,8 +126,8 @@ class Customer < ActiveRecord::Base end # Push the updates - def save_with_push - save_without_push + def self.save_with_push + self.save_without_push begin #tries ||= 3 @details = Qbo.get_base(:customer).service.update(@details)