From 6c9215c334b4ffb25120c9d96d51195c6a3e735c Mon Sep 17 00:00:00 2001 From: JoenioCosta Date: Wed, 11 Jun 2008 02:08:19 +0000 Subject: [PATCH] ActionItem261: dont add the same product of enterprise twice --- script/fbes_populate_helper.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/script/fbes_populate_helper.rb b/script/fbes_populate_helper.rb index f6193b4..787d9b0 100644 --- a/script/fbes_populate_helper.rb +++ b/script/fbes_populate_helper.rb @@ -45,15 +45,14 @@ require File.dirname(__FILE__) + '/../config/environment' end def new_ent(data, products, consumptions) - posfix = '' count = 1 - while Enterprise.find_by_identifier(data[:identifier] = (data[:identifier] + posfix)) do + while Enterprise.find_by_identifier(data[:identifier]) + data[:identifier] = data[:identifier] + "-#{count}" count += 1 - posfix = "-#{count}" end ent = Enterprise.create!({:environment => Environment.default}.merge(data)) products.each do |p| - ent.products.create!(p) + ent.products.create!(p) unless ent.products.find(:first, :conditions => p) end consumptions.each do |c| ent.consumptions.create!(c) unless ent.consumptions.find(:first, :conditions => c) -- libgit2 0.21.2