From b771199e3dbd011efe114926f57e4f6ed9bf972f Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Tue, 17 May 2016 11:06:10 -0400 Subject: [PATCH] Update qbo_item.rb --- app/models/qbo_item.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/qbo_item.rb b/app/models/qbo_item.rb index d78293f..0ed829f 100644 --- a/app/models/qbo_item.rb +++ b/app/models/qbo_item.rb @@ -21,6 +21,8 @@ class QboItem < ActiveRecord::Base def self.sync last = Qbo.first.last_sync + QboItem.delete_all + query = "SELECT Id, Name FROM Item " query << " WHERE Type = 'Service' " #query << " AND Metadata.LastUpdatedTime > '#{last}' " if last @@ -34,9 +36,9 @@ class QboItem < ActiveRecord::Base qbo_item.id = item.id qbo_item.save } + + QboItem.where.not(items.map(&:id)).destroy_all end - - #remove deleted items - QboItem.where.not(items.map(&:id)).destroy_all end + end