Commit 50a4e204c1a42aa512b42eb10f16f3751b3769ad

Authored by Joenio Costa
1 parent bd33b5fb

Saving products without validation in migration to set category to products without category

(ActionItem1593)
db/migrate/20100621235235_set_product_category_id_to_products.rb
@@ -2,8 +2,7 @@ class SetProductCategoryIdToProducts < ActiveRecord::Migration @@ -2,8 +2,7 @@ class SetProductCategoryIdToProducts < ActiveRecord::Migration
2 def self.up 2 def self.up
3 Product.all(:conditions => { :product_category_id => nil }).each do |product| 3 Product.all(:conditions => { :product_category_id => nil }).each do |product|
4 next if product.enterprise.nil? 4 next if product.enterprise.nil?
5 - product.product_category = ProductCategory.top_level_for(product.enterprise.environment).first  
6 - product.save! 5 + product.update_attribute(:product_category_id, ProductCategory.top_level_for(product.enterprise.environment).first.id)
7 end 6 end
8 end 7 end
9 8