Sha256: 120384f6740b523bf6666447396e975c2836eb571d06e26a874c92e214190bb0

Contents?: true

Size: 639 Bytes

Versions: 1

Compression:

Stored size: 639 Bytes

Contents

require_dependency "shopping_cart/application_controller"

module ShoppingCart
  class OrderItemsController < ApplicationController
    before_action :order_item, only: %i[update destroy]

    def create
      CreateOrderItem.call(params: permited_params, order: current_order) do
        on(:ok) { render :create }
      end
    end

    def update
      @order_item.update(quantity: params[:quantity])
    end

    def destroy
      @order_item.destroy
    end

    private

    def permited_params
      params.permit(:quantity, :product_id)
    end

    def order_item
      @order_item = OrderItem.find(params[:id])
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
loker-shopping-cart-0.1.3 app/controllers/shopping_cart/order_items_controller.rb