Commit 56d303cc73eac389cb00c5860d3922e274fb2559

Authored by Joenio Costa
1 parent 4f988b2f

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