From da59bf4c8a16b75f560782fa2fcc34396ea27d02 Mon Sep 17 00:00:00 2001 From: Charles-Andre Bouffard Date: Fri, 9 Oct 2015 14:07:21 -0400 Subject: [PATCH] Add the ability to run the seeds multiple times We have to have the ability to run the seeds multiple time without it giving errors about records were already existing. --- core/db/default/spree/zones.rb | 4 ++-- sample/db/samples/tax_categories.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/db/default/spree/zones.rb b/core/db/default/spree/zones.rb index 35fdccac6c1..6e2c7216ff9 100644 --- a/core/db/default/spree/zones.rb +++ b/core/db/default/spree/zones.rb @@ -1,5 +1,5 @@ -eu_vat = Spree::Zone.create!(name: "EU_VAT", description: "Countries that make up the EU VAT zone.") -north_america = Spree::Zone.create!(name: "North America", description: "USA + Canada") +eu_vat = Spree::Zone.find_or_create_by!(name: "EU_VAT", description: "Countries that make up the EU VAT zone.") +north_america = Spree::Zone.find_or_create_by!(name: "North America", description: "USA + Canada") ["Poland", "Finland", "Portugal", "Romania", "Germany", "France", "Slovakia", "Hungary", "Slovenia", "Ireland", "Austria", "Spain", diff --git a/sample/db/samples/tax_categories.rb b/sample/db/samples/tax_categories.rb index 95120a0b21e..0ce42614302 100644 --- a/sample/db/samples/tax_categories.rb +++ b/sample/db/samples/tax_categories.rb @@ -1 +1 @@ -Spree::TaxCategory.create!(:name => "Default") +Spree::TaxCategory.create!(:name => Spree::TaxCategory.find_by!(:name => "Default"))