Sha256: 854369defa6ea69e3af1aeed8872d7f88681d308264d2657762ffc33ad8ca5ee

Contents?: true

Size: 1015 Bytes

Versions: 8

Compression:

Stored size: 1015 Bytes

Contents

module Comee
  module Core
    class ProductsController < ApplicationController
      include Common

      def index
        super do
          products = Product.leafs
          products.then(&paginate)
        end
      end

      def show
        super do
          product = Comee::Core::Product.with_attached_images.find(params[:id])
          product
        end
      end

      def master_prices
        data = MasterPrice.where(product_id: price_params[:product_ids])
        render json: {success: true, data: serialize(data)}
      end

      def client_prices
        data = ClientPrice.where(product_id: price_params[:product_ids])
        render json: {success: true, data: serialize(data)}
      end

      private

      def model_params
        params.required(:payload).permit(:code, :name, :description, :parent_id, :thumbnail_image, :preferred_units, :source_id, images: [])
      end

      def price_params
        params.require(:payload).permit(product_ids: [])
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
comee_core-0.1.61 app/controllers/comee/core/products_controller.rb
comee_core-0.1.60 app/controllers/comee/core/products_controller.rb
comee_core-0.1.59 app/controllers/comee/core/products_controller.rb
comee_core-0.1.58 app/controllers/comee/core/products_controller.rb
comee_core-0.1.57 app/controllers/comee/core/products_controller.rb
comee_core-0.1.56 app/controllers/comee/core/products_controller.rb
comee_core-0.1.55 app/controllers/comee/core/products_controller.rb
comee_core-0.1.54 app/controllers/comee/core/products_controller.rb