Class: Cats::Core::CommodityCategoriesController

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

#allObject



12
13
14
15
# File 'app/controllers/cats/core/commodity_categories_controller.rb', line 12

def all
  data = CommodityCategory.all
  render json: {success: true, data: data}
end

#childrenObject



22
23
24
25
# File 'app/controllers/cats/core/commodity_categories_controller.rb', line 22

def children
  parent = CommodityCategory.find(params[:id])
  render json: {success: true, data: serialize(parent.children)}
end

#indexObject



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

def index
  super do
    CommodityCategory.all.reject(&:has_children?)
  end
end

#rootObject



17
18
19
20
# File 'app/controllers/cats/core/commodity_categories_controller.rb', line 17

def root
  data = CommodityCategory.roots
  render json: {success: true, data: serialize(data)}
end