Class: Kms::Shop::OrdersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/kms/shop/orders_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



18
19
20
21
# File 'app/controllers/kms/shop/orders_controller.rb', line 18

def destroy
  @order = Kms::Order.find(params[:id])
  @order.destroy
end

#indexObject



5
6
7
# File 'app/controllers/kms/shop/orders_controller.rb', line 5

def index
  render json: Order.order('created_at desc'), root: false, scope: current_kms_user
end

#updateObject



9
10
11
12
13
14
15
16
# File 'app/controllers/kms/shop/orders_controller.rb', line 9

def update
  @order = Kms::Order.find(params[:id])
  if @order.update(order_params)
    head :no_content
  else
    render json: {errors: @order.errors}.to_json, status: :unprocessable_entity
  end
end