Sha256: bbedc71530b40ba3ed16270162c216bc559745a7982f62915ca9de65c6b8142d
Contents?: true
Size: 1.45 KB
Versions: 11
Compression:
Stored size: 1.45 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.includes(:product_lookup, :supplier, :product) .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 categories root = Product.find_by(code: "root") render json: {success: true, data: serialize(root.children)} 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
11 entries across 11 versions & 1 rubygems