From 50a4e204c1a42aa512b42eb10f16f3751b3769ad Mon Sep 17 00:00:00 2001 From: Joenio Costa Date: Wed, 21 Jul 2010 23:35:30 -0300 Subject: [PATCH] Saving products without validation in migration to set category to products without category --- db/migrate/20100621235235_set_product_category_id_to_products.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/db/migrate/20100621235235_set_product_category_id_to_products.rb b/db/migrate/20100621235235_set_product_category_id_to_products.rb index b271b0c..614172f 100644 --- a/db/migrate/20100621235235_set_product_category_id_to_products.rb +++ b/db/migrate/20100621235235_set_product_category_id_to_products.rb @@ -2,8 +2,7 @@ class SetProductCategoryIdToProducts < ActiveRecord::Migration def self.up Product.all(:conditions => { :product_category_id => nil }).each do |product| next if product.enterprise.nil? - product.product_category = ProductCategory.top_level_for(product.enterprise.environment).first - product.save! + product.update_attribute(:product_category_id, ProductCategory.top_level_for(product.enterprise.environment).first.id) end end -- libgit2 0.21.2