Class: ShoppingCart::OrdersController

Inherits:
ApplicationController show all
Includes:
StandardFlashes
Defined in:
app/controllers/shopping_cart/orders_controller.rb

Instance Method Summary collapse

Methods included from StandardFlashes

#create_order_failed, #update_error, #updated_notice

Instance Method Details

#createObject



26
27
28
29
30
31
# File 'app/controllers/shopping_cart/orders_controller.rb', line 26

def create
  CreateOrder.call(params) do
    on(:ok)       { redirect_to root_path }
    on(:invalid)  { create_order_failed }
  end
end

#destroyObject



21
22
23
24
# File 'app/controllers/shopping_cart/orders_controller.rb', line 21

def destroy
  @order.destroy
  redirect_to root_path
end

#editObject



9
10
11
# File 'app/controllers/shopping_cart/orders_controller.rb', line 9

def edit
  @order = OrderInProgress.new(current_user.id).query
end

#updateObject



13
14
15
16
17
18
19
# File 'app/controllers/shopping_cart/orders_controller.rb', line 13

def update
  UpdateOrder.call(@order, params) do
    on(:ok)      { updated_notice('Order') }
    on(:invalid) { update_error('Order') }
  end
  redirect_to root_path
end