From 22c11d91ee3e72b34763ea18640ac19021e1587a Mon Sep 17 00:00:00 2001 From: Dan <34167503+jontarg@users.noreply.github.com> Date: Thu, 10 Jan 2019 00:50:06 -0600 Subject: [PATCH] Make zone members creation idempotent --- core/db/default/spree/zones.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/db/default/spree/zones.rb b/core/db/default/spree/zones.rb index bc81192fbe2..f02169f68ce 100644 --- a/core/db/default/spree/zones.rb +++ b/core/db/default/spree/zones.rb @@ -5,9 +5,9 @@ %w(PL FI PT RO DE FR SK HU SI IE AT ES IT BE SE LV BG GB LT CY LU MT DK NL EE HR CZ GR). each do |symbol| - eu_vat.zone_members.create!(zoneable: Spree::Country.find_by!(iso: symbol)) + eu_vat.zone_members.find_or_create_by!(zoneable: Spree::Country.find_by!(iso: symbol)) end %w(US CA).each do |symbol| - north_america.zone_members.create!(zoneable: Spree::Country.find_by!(iso: symbol)) + north_america.zone_members.find_or_create_by!(zoneable: Spree::Country.find_by!(iso: symbol)) end