workaround receive error with many articles

This commit is contained in:
wvengen 2014-08-22 09:35:05 +02:00
parent 63d52db91b
commit d906a7342f

View file

@ -145,7 +145,9 @@ class OrdersController < ApplicationController
# changed, rest_to_tolerance, rest_to_stock, left_over # changed, rest_to_tolerance, rest_to_stock, left_over
counts = [0] * 4 counts = [0] * 4
cunits = [0] * 4 cunits = [0] * 4
OrderArticle.transaction do # This was once wrapped in a transaction, but caused
# "MySQL lock timeout exceeded" errors. It's ok to do
# this article-by-article anway.
params[:order_articles].each do |oa_id, oa_params| params[:order_articles].each do |oa_id, oa_params|
unless oa_params.blank? unless oa_params.blank?
oa = OrderArticle.find(oa_id) oa = OrderArticle.find(oa_id)
@ -163,7 +165,6 @@ class OrdersController < ApplicationController
oa.save! oa.save!
end end
end end
end
return nil if counts[0] == 0 return nil if counts[0] == 0
notice = [] notice = []
notice << I18n.t('orders.update_order_amounts.msg1', count: counts[0], units: cunits[0]) notice << I18n.t('orders.update_order_amounts.msg1', count: counts[0], units: cunits[0])