Merge pull request #185 from foodcoop-rostock/force-order-finish

Force update_attributes! in Order#finish; rescue if error raised
This commit is contained in:
wvengen 2013-10-10 08:30:33 -07:00
commit 9cb5362e48
2 changed files with 3 additions and 1 deletions

View file

@ -98,6 +98,8 @@ class OrdersController < ApplicationController
order = Order.find(params[:id])
order.finish!(@current_user)
redirect_to order, notice: I18n.t('orders.finish.notice')
rescue => error
redirect_to orders_url, alert: I18n.t('errors.general_msg', :msg => error.message)
end
# Renders the fax-text-file

View file

@ -155,7 +155,7 @@ class Order < ActiveRecord::Base
unless finished?
Order.transaction do
# set new order state (needed by notify_order_finished)
update_attributes(:state => 'finished', :ends => Time.now, :updated_by => user)
update_attributes!(:state => 'finished', :ends => Time.now, :updated_by => user)
# Update order_articles. Save the current article_price to keep price consistency
# Also save results for each group_order_result