app/models/disco_app/concerns/synchronises.rb in disco_app-0.10.4 vs app/models/disco_app/concerns/synchronises.rb in disco_app-0.10.5

- old
+ new

@@ -8,16 +8,20 @@ def should_synchronise?(shop, data) true end + def synchronise_by(shop, data) + { id: data[:id] } + end + def synchronise(shop, data) data = data.with_indifferent_access return unless should_synchronise?(shop, data) begin - instance = self.find_or_create_by!(id: data[:id]) do |instance| + instance = self.find_or_create_by!(self.synchronise_by(shop, data)) do |instance| instance.shop = shop instance.data = data end rescue ActiveRecord::RecordNotUnique, PG::UniqueViolation retry