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

Methods inherited from ApplicationController

#set_view_path

Instance Method Details

#createObject



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

def create
  @order.next_state!

  flash.now[:notice] = Comable.t('orders.success')
  send_order_complete_mail
rescue ActiveRecord::RecordInvalid, Comable::PaymentError
  flash[:alert] = @order.errors.full_messages.join
  redirect_to next_order_path
end

#editObject



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

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

#updateObject



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

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