Module: Spree::CheckoutControllerDecorator

Defined in:
lib/decorators/frontend/controllers/spree/checkout_controller_decorator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/decorators/frontend/controllers/spree/checkout_controller_decorator.rb', line 5

def self.prepended(base)
  base.before_action :check_registration, except: [:registration, :update_registration]
  base.before_action :check_authorization

  # This action builds some associations on the order, ex. addresses, which we
  # don't want to build or save here.
  base.skip_before_action :setup_for_current_state, only: [:registration, :update_registration]
end

Instance Method Details

#registrationObject



14
15
16
# File 'lib/decorators/frontend/controllers/spree/checkout_controller_decorator.rb', line 14

def registration
  @user = Spree::User.new
end

#update_registrationObject



18
19
20
21
22
23
24
25
26
# File 'lib/decorators/frontend/controllers/spree/checkout_controller_decorator.rb', line 18

def update_registration
  if params[:order][:email] =~ Devise.email_regexp && current_order.update(email: params[:order][:email])
    redirect_to spree.checkout_path
  else
    flash[:registration_error] = t(:email_is_invalid, scope: [:errors, :messages])
    @user = Spree::User.new
    render 'registration'
  end
end