From 882d7a121541e07ee7f607e0580641233374e82a Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 25 Jan 2023 15:47:35 +1100 Subject: [PATCH] Simplify method according to style rules --- app/controllers/split_checkout_controller.rb | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/controllers/split_checkout_controller.rb b/app/controllers/split_checkout_controller.rb index 28cc0220b2..6ded33fb28 100644 --- a/app/controllers/split_checkout_controller.rb +++ b/app/controllers/split_checkout_controller.rb @@ -36,14 +36,7 @@ class SplitCheckoutController < ::BaseController advance_order_state redirect_to_step else - flash.now[:error] ||= I18n.t( - 'split_checkout.errors.saving_failed', - messages: @order.errors.full_messages.to_sentence - ) - - render status: :unprocessable_entity, operations: cable_car. - replace("#checkout", partial("split_checkout/checkout")). - replace("#flashes", partial("shared/flashes", locals: { flashes: flash })) + render_error end rescue Spree::Core::GatewayError => e flash[:error] = I18n.t(:spree_gateway_error_flash_for_checkout, error: e.message) @@ -53,6 +46,17 @@ class SplitCheckoutController < ::BaseController private + def render_error + flash.now[:error] ||= I18n.t( + 'split_checkout.errors.saving_failed', + messages: @order.errors.full_messages.to_sentence + ) + + render status: :unprocessable_entity, operations: cable_car. + replace("#checkout", partial("split_checkout/checkout")). + replace("#flashes", partial("shared/flashes", locals: { flashes: flash })) + end + def flash_error_when_no_shipping_method_available flash[:error] = I18n.t('split_checkout.errors.no_shipping_methods_available') end