Fixed ensure_open_order filter on missing id params.
This commit is contained in:
parent
d9e8f29d44
commit
cc4e925c1a
1 changed files with 8 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue