From 045ce73c832008aad3fcada5659841d788213e4b Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 30 Apr 2021 12:16:22 +0100 Subject: [PATCH] Simplify shipment controller params --- app/controllers/api/v0/shipments_controller.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/v0/shipments_controller.rb b/app/controllers/api/v0/shipments_controller.rb index c885d1c221..0d92b5915a 100644 --- a/app/controllers/api/v0/shipments_controller.rb +++ b/app/controllers/api/v0/shipments_controller.rb @@ -34,7 +34,7 @@ module Api @shipment.fee_adjustment.open end - @shipment.update(shipment_params[:shipment]) + @shipment.update(shipment_params) if unlock == 'yes' @shipment.fee_adjustment.close @@ -94,7 +94,7 @@ module Api def find_and_update_shipment @shipment = @order.shipments.find_by!(number: params[:id]) - @shipment.update(shipment_params[:shipment]) if shipment_params[:shipment].present? + @shipment.update(shipment_params) @shipment.reload end @@ -113,10 +113,9 @@ module Api end def shipment_params - params.permit( - [:id, :order_id, :variant_id, :quantity, - { shipment: [:tracking, :selected_shipping_rate_id] }] - ) + return {} unless params.has_key? :shipment + + params.require(:shipment).permit(:tracking, :selected_shipping_rate_id) end end end