updating part2, far from finished

This commit is contained in:
2013-12-20 19:22:12 +01:00
parent 748944865d
commit b4c4a15e60
22 changed files with 2779 additions and 62 deletions
+15 -5
View File
@@ -21,15 +21,25 @@ class Product
def product_category_ids=(ids)
@product_category_ids = ids.select(&:present?)
is_dirty
end
private
def persist_product_category_ids
return unless @product_category_ids.present?
database.load(@product_category_ids).each do |product_category|
product_category.product_ids ||= []
product_category.product_ids |= [id]
product_category.save
@product_category_ids ||= []
existing_product_categories = product_categories
# do nothing if nothing has changed
return if @product_category_ids == existing_product_categories.map(&:id)
# clear removed product categories
existing_product_categories.reject{|pc| @product_category_ids.include?(pc.id) }.each{|pc| pc.remove_product(self) }
# Add product to newly added product categories
database.load(@product_category_ids - existing_product_categories.map(&:id)).each do |product_category|
product_category.add_product(self)
end
end
+1
View File
@@ -130,6 +130,7 @@ class Section
end
return saves.all?
end
def arrange_tables_in_columns_of(n)
return unless n.present?
n = n.to_i