Module: Spree::CheckoutControllerDecorator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



3
4
5
6
# File 'lib/controllers/frontend/spree/checkout_controller_decorator.rb', line 3

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

Instance Method Details

#registrationObject



8
9
10
11
# File 'lib/controllers/frontend/spree/checkout_controller_decorator.rb', line 8

def registration
  @user = Spree.user_class.new 
  @title = Spree.t(:registration)
end

#update_registrationObject



13
14
15
16
17
18
19
20
21
# File 'lib/controllers/frontend/spree/checkout_controller_decorator.rb', line 13

def update_registration
  if order_params[:email] =~ Devise.email_regexp && current_order.update_attribute(:email, order_params[:email])
    redirect_to spree.checkout_state_path(:address)
  else
    flash[:error] = t(:email_is_invalid, scope: [:errors, :messages])
    @user = Spree.user_class.new
    render 'registration'
  end
end