Class: Cats::Core::CommoditiesController
Instance Method Summary
collapse
Methods included from Common
#create, #show, #update
#authenticate, #current_user, #skip_bullet
Instance Method Details
#approve ⇒ Object
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
|
#filter ⇒ Object
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
|
#index ⇒ Object
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
|