Fixed ensure_open_order filter on missing id params.

This commit is contained in:
Benjamin Meichsner 2014-09-23 10:39:10 +02:00
parent d9e8f29d44
commit cc4e925c1a

View file

@ -74,11 +74,13 @@ class GroupOrdersController < ApplicationController
end
def ensure_open_order
@order = Order.includes([:supplier, :order_articles]).find(params[:order_id] || params[:group_order][:order_id])
@order = Order.includes([:supplier, :order_articles]).find(order_id_param)
unless @order.open?
flash[:notice] = I18n.t('group_orders.errors.closed')
redirect_to :action => 'index'
end
rescue ActiveRecord::RecordNotFound
redirect_to group_orders_url, alert: I18n.t('group_orders.errors.notfound')
end
def ensure_my_group_order
@ -95,4 +97,8 @@ class GroupOrdersController < ApplicationController
end
end
def order_id_param
params[:order_id] || (params[:group_order] && params[:group_order][:order_id])
end
end