Simplify shipment controller params

This commit is contained in:
Matt-Yorkley
2021-04-30 12:16:22 +01:00
parent 932d000c9d
commit 045ce73c83

View File

@@ -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