Class: Comable::OrdersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/comable/orders_controller.rb

Instance Method Summary collapse

Methods included from ApplicationHelper

#current_customer

Instance Method Details

#confirmObject



27
28
29
# File 'app/controllers/comable/orders_controller.rb', line 27

def confirm
  @order = current_customer.preorder(build_order_nested_attributes)
end

#createObject



31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/comable/orders_controller.rb', line 31

def create
  @order = current_customer.order(build_order_nested_attributes)
  if @order.valid?
    flash[:notice] = I18n.t('comable.orders.success')
    reset_session
  else
    flash[:alert] = I18n.t('comable.orders.failure')
    redirect_to comable.confirm_order_path
  end
end

#deliveryObject



18
19
20
21
22
23
24
25
# File 'app/controllers/comable/orders_controller.rb', line 18

def delivery
  case request.method_symbol
  when :post
    redirect_to comable.confirm_order_path
  when :get
    @order.order_deliveries.build if @order.order_deliveries.empty?
  end
end

#newObject



8
9
# File 'app/controllers/comable/orders_controller.rb', line 8

def new
end

#ordererObject



11
12
13
14
15
16
# File 'app/controllers/comable/orders_controller.rb', line 11

def orderer
  case request.method_symbol
  when :post
    redirect_to comable.delivery_order_path
  end
end