# frozen_string_literal: true module C class Front::Devise::RegistrationsController < Devise::RegistrationsController layout 'c/main_application' def after_sign_up_path_for(resource) if session[:cart_id].present? begin customer = current_front_customer_account.customer cart = C::Cart.find(session[:cart_id]) cart.update(customer_id: customer.id) cart.order.update(customer: customer) if cart.order.present? rescue ActiveRecord::RecordNotFound # Do nothing, as there is nothing to set end session.delete(:cart_id) end params['checkout'] ? new_checkout_path : super end private def sign_up_params h = params.require(:front_customer_account).permit( :email, :password, :password_confirmation, customer_attributes: [:name] ) h[:customer_attributes][:email] = h[:email] h end end end