Class: Comee::Core::ProductsController

Inherits:
ApplicationController show all
Includes:
Common
Defined in:
app/controllers/comee/core/products_controller.rb

Instance Method Summary collapse

Methods included from Common

#create, #update

Methods included from Pagination

#default_per_page, #order_by, #order_direction, #page_no, #paginate, #paginate_offset, #per_page

Methods inherited from ApplicationController

#application_code, #authenticate, #current_application, #current_user, #render_content, #render_error, #skip_bullet

Instance Method Details

#categoriesObject



29
30
31
32
# File 'app/controllers/comee/core/products_controller.rb', line 29

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

#client_pricesObject



24
25
26
27
# File 'app/controllers/comee/core/products_controller.rb', line 24

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

#customersObject



34
35
36
37
38
# File 'app/controllers/comee/core/products_controller.rb', line 34

def customers
  clients = ProductLookup.where(product_id: params[:id], itemable_type: "Comee::Core::Client")
                         .map(&:itemable)
  render_content(clients)
end

#filterObject



40
41
42
43
# File 'app/controllers/comee/core/products_controller.rb', line 40

def filter
  data = Product.ransack(params[:q]).result
  render_content(data)
end

#indexObject



6
7
8
9
10
# File 'app/controllers/comee/core/products_controller.rb', line 6

def index
  super do
    Product.leafs
  end
end

#master_pricesObject



18
19
20
21
22
# File 'app/controllers/comee/core/products_controller.rb', line 18

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

#showObject



12
13
14
15
16
# File 'app/controllers/comee/core/products_controller.rb', line 12

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