Merge pull request #116 from balkansalat/rails3-balancing-delete-article

Update ordergroup prices in OrderArticles via Order.
This commit is contained in:
Benjamin Meichsner 2013-06-09 08:26:38 -07:00
commit 60afa85ece

View file

@ -148,7 +148,10 @@ class OrderArticle < ActiveRecord::Base
end end
def update_ordergroup_prices def update_ordergroup_prices
group_order_articles.each { |goa| goa.group_order.update_price! } # updates prices of ALL ordergroups - these are actually too many
# in case of performance issues, update only ordergroups, which ordered this article
# CAUTION: in after_destroy callback related records (e.g. group_order_articles) are already non-existent
order.group_orders.each { |go| go.update_price! }
end end
end end