Class: Cats::Core::DispatchPlanItemsController

Inherits:
ApplicationController show all
Includes:
Common
Defined in:
app/controllers/cats/core/dispatch_plan_items_controller.rb

Instance Method Summary collapse

Methods included from Common

#create, #show, #update

Methods inherited from ApplicationController

#authenticate, #current_user, #skip_bullet

Instance Method Details

#filterObject



18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/cats/core/dispatch_plan_items_controller.rb', line 18

def filter
  query = DispatchPlanItem.includes(
    :source,
    :destination,
    {commodity: {project: {source: :commodity_category}}},
    :unit,
    :dispatch_plan
  ).ransack(params[:q])
  render json: {success: true, data: serialize(query.result)}
end

#indexObject



6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/cats/core/dispatch_plan_items_controller.rb', line 6

def index
  super do
    DispatchPlanItem.includes(
      :source,
      :destination,
      {commodity: {project: {source: :commodity_category}}},
      :unit,
      :dispatch_plan
    ).where(dispatch_plan_id: params[:id])
  end
end