Handle bad entries when creating new order articles in balancing
controller.
This commit is contained in:
parent
5a93ca1641
commit
21f128ef1d
1 changed files with 8 additions and 1 deletions
|
@ -95,7 +95,8 @@ class Finance::BalancingController < ApplicationController
|
|||
|
||||
def create_order_article
|
||||
@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
|
||||
# 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"
|
||||
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
|
||||
|
||||
def edit_order_article
|
||||
|
|
Loading…
Reference in a new issue