Handle bad entries when creating new order articles in balancing

controller.
This commit is contained in:
Benjamin Meichsner 2009-09-07 13:31:03 +02:00
parent 5a93ca1641
commit 21f128ef1d

View file

@ -95,7 +95,8 @@ class Finance::BalancingController < ApplicationController
def create_order_article def create_order_article
@order = Order.find(params[:order_id]) @order = Order.find(params[:order_id])
order_article = @order.order_articles.find_by_article_id(params[:order_article][:article_id]) article = Article.find(params[:order_article][:article_id])
order_article = @order.order_articles.find_by_article_id(article.id)
unless order_article unless order_article
# Article wasn't already assigned with this order, lets create a new one # Article wasn't already assigned with this order, lets create a new one
@ -115,6 +116,12 @@ class Finance::BalancingController < ApplicationController
page["edit_box"].replace_html :partial => "new_order_article" page["edit_box"].replace_html :partial => "new_order_article"
end end
end end
rescue
render :update do |page|
page.replace_html "edit_box", :text => "<b>Keinen Artikel gefunden. Bitte erneut versuchen.</b>"
page.insert_html :bottom, "edit_box", :partial => "new_order_article"
end
end end
def edit_order_article def edit_order_article