Sha256: a2cc4cddc8b0b51f3542063ed935707fc8b657500bed6ff4bd41c04929b51f0c

Contents?: true

Size: 1.24 KB

Versions: 20

Compression:

Stored size: 1.24 KB

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

      def filter
        products = Product.ransack(params[:q]).result
        render json: {success: true, data: serialize(products)}
      end

      private

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

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
comee_core-0.1.83 app/controllers/comee/core/products_controller.rb
comee_core-0.1.82 app/controllers/comee/core/products_controller.rb
comee_core-0.1.81 app/controllers/comee/core/products_controller.rb
comee_core-0.1.80 app/controllers/comee/core/products_controller.rb
comee_core-0.1.79 app/controllers/comee/core/products_controller.rb
comee_core-0.1.78 app/controllers/comee/core/products_controller.rb
comee_core-0.1.77 app/controllers/comee/core/products_controller.rb
comee_core-0.1.76 app/controllers/comee/core/products_controller.rb
comee_core-0.1.75 app/controllers/comee/core/products_controller.rb
comee_core-0.1.74 app/controllers/comee/core/products_controller.rb
comee_core-0.1.73 app/controllers/comee/core/products_controller.rb
comee_core-0.1.72 app/controllers/comee/core/products_controller.rb
comee_core-0.1.71 app/controllers/comee/core/products_controller.rb
comee_core-0.1.70 app/controllers/comee/core/products_controller.rb
comee_core-0.1.69 app/controllers/comee/core/products_controller.rb
comee_core-0.1.68 app/controllers/comee/core/products_controller.rb
comee_core-0.1.67 app/controllers/comee/core/products_controller.rb
comee_core-0.1.66 app/controllers/comee/core/products_controller.rb
comee_core-0.1.65 app/controllers/comee/core/products_controller.rb
comee_core-0.1.64 app/controllers/comee/core/products_controller.rb