Class: Comable::OrdersController

Inherits:
ApplicationController show all
Includes:
PaymentAction, PermittedAttributes, ShipmentAction, SigninAction
Defined in:
app/controllers/comable/orders_controller.rb

Instance Method Summary collapse

Methods included from SigninAction

#guest, prepended

Instance Method Details

#createObject



29
30
31
32
33
34
35
36
37
# File 'app/controllers/comable/orders_controller.rb', line 29

def create
  if @order.state?(:confirm) && @order.next_state
    flash.now[:notice] = Comable.t('orders.success')
    send_order_complete_mail
  else
    flash[:alert] = Comable.t('orders.failure')
    redirect_to next_order_path
  end
end

#editObject



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

def edit
  if @order.state?(params[:state]) || @order.stated?(params[:state])
    render params[:state]
  else
    redirect_to next_order_path
  end
end

#updateObject



21
22
23
24
25
26
27
# File 'app/controllers/comable/orders_controller.rb', line 21

def update
  if @order.stated?(params[:state]) ? @order.save : @order.next_state
    redirect_to next_order_path
  else
    render @order.state
  end
end