I have to pass a array of food_item_ids in my order_controller. Every order will have many food_items. How can I pass these food_items_id as an array in strong parameters.
orders_controller.rb
def create
@order = Order.new(order_params)
if @order.save
render :json, @order, status:201, location: [:api, @order]
else
render :json, { errors: @order.errors }, status:422
end
end
private
def order_params
params.require(:order).permit(:customer_id, :order_id, :pos_id, :table_id, :order_number,
:order_status,:order_date, :food_item_id => [])
end
end
Is this the right way to send an array in strong params :food_item_id => []