Class: Cats::Core::CommoditiesController

Inherits:
ApplicationController show all
Includes:
Common
Defined in:
app/controllers/cats/core/commodities_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

#approveObject



12
13
14
15
16
17
18
# File 'app/controllers/cats/core/commodities_controller.rb', line 12

def approve
  commodity = Commodity.find(params[:id])
  result = commodity.approve
  render json: {success: result, data: serialize(commodity)}
rescue StandardError => e
  render json: {success: false, error: e.message}
end

#filterObject



20
21
22
23
# File 'app/controllers/cats/core/commodities_controller.rb', line 20

def filter
  query = Commodity.includes(:project, :unit_of_measure, :package_unit).ransack(params[:q])
  render json: {success: true, data: serialize(query.result)}
end

#indexObject



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

def index
  super do
    Commodity.all.includes({project: {source: :commodity_category}}, :unit_of_measure, :package_unit)
  end
end