Update customer.rb

This commit is contained in:
2016-05-16 17:38:36 -04:00
parent eeccece2a7
commit 454613c1ba

View File

@@ -108,12 +108,15 @@ class Customer < ActiveRecord::Base
transaction do transaction do
# Update the customer table # Update the customer table
customers.each { |customer| customers.each { |customer|
qbo_customer = Customer.find_or_create_by(id: customer.id)
# only update if diffrent background do
if qbo_customer.new_record? qbo_customer = Customer.find_or_create_by(id: customer.id)
qbo_customer.name = customer.display_name # only update if diffrent
qbo_customer.id = customer.id if qbo_customer.new_record?
qbo_customer.save! qbo_customer.name = customer.display_name
qbo_customer.id = customer.id
qbo_customer.save!
end
end end
} }
end end
@@ -130,6 +133,13 @@ class Customer < ActiveRecord::Base
private private
def background(&block)
Thread.new do
yield
ActiveRecord::Base.connection.close
end
end
# pull the details # pull the details
def pull def pull
begin begin