Sha256: 2b53514fa5b84e6364639b900230ed65c07ac01667ca3afd3c4e2aea22088c01

Contents?: true

Size: 1.25 KB

Versions: 69

Compression:

Stored size: 1.25 KB

Contents

module Comee
  module Core
    class ProductsController < ApplicationController
      include Common

      def index
        super do
          Product.leafs
        end
      end

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

      def master_prices
        data = MasterPrice.includes(:product_lookup, :supplier, :product)
                          .where(product_id: price_params[:product_ids])
        render_content(data)
      end

      def client_prices
        data = ClientPrice.where(product_id: price_params[:product_ids])
        render_content(data)
      end

      def categories
        root = Product.find_by(code: "root")
        render_content(root.children)
      end

      def filter
        data = Product.ransack(params[:q]).result
        render_content(data)
      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

69 entries across 69 versions & 1 rubygems

Version Path
comee_core-0.2.65 app/controllers/comee/core/products_controller.rb
comee_core-0.2.64 app/controllers/comee/core/products_controller.rb
comee_core-0.2.63 app/controllers/comee/core/products_controller.rb
comee_core-0.2.62 app/controllers/comee/core/products_controller.rb
comee_core-0.2.61 app/controllers/comee/core/products_controller.rb
comee_core-0.2.60 app/controllers/comee/core/products_controller.rb
comee_core-0.2.59 app/controllers/comee/core/products_controller.rb
comee_core-0.2.58 app/controllers/comee/core/products_controller.rb
comee_core-0.2.57 app/controllers/comee/core/products_controller.rb
comee_core-0.2.56 app/controllers/comee/core/products_controller.rb
comee_core-0.2.55 app/controllers/comee/core/products_controller.rb
comee_core-0.2.54 app/controllers/comee/core/products_controller.rb
comee_core-0.2.53 app/controllers/comee/core/products_controller.rb
comee_core-0.2.52 app/controllers/comee/core/products_controller.rb
comee_core-0.2.51 app/controllers/comee/core/products_controller.rb
comee_core-0.2.50 app/controllers/comee/core/products_controller.rb
comee_core-0.2.49 app/controllers/comee/core/products_controller.rb
comee_core-0.2.48 app/controllers/comee/core/products_controller.rb
comee_core-0.2.47 app/controllers/comee/core/products_controller.rb
comee_core-0.2.46 app/controllers/comee/core/products_controller.rb