Class: CategoriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


30
31
32
33
34
35
36
# File 'app/controllers/categories_controller.rb', line 30

def create
  @category = Category.new(category_params)
  authorize @category
  @category.save

  respond_with(@category)
end

#destroyObject


43
44
45
46
# File 'app/controllers/categories_controller.rb', line 43

def destroy
  @category.destroy
  respond_with(@category)
end

#editObject


27
28
# File 'app/controllers/categories_controller.rb', line 27

def edit
end

#indexObject


7
8
9
10
11
# File 'app/controllers/categories_controller.rb', line 7

def index
  @categories = Category.roots

  respond_with(@categories)
end

#newObject


19
20
21
22
23
24
25
# File 'app/controllers/categories_controller.rb', line 19

def new
  @category = Category.new
  authorize @category    
  @category.parent_id = params[:parent_id]
  
  respond_with(@category)
end

#showObject


13
14
15
16
17
# File 'app/controllers/categories_controller.rb', line 13

def show
  @children = @category.children

  respond_with(@category, @children)
end

#updateObject


38
39
40
41
# File 'app/controllers/categories_controller.rb', line 38

def update
  @category.update(category_params)
  respond_with(@category)
end