Class: CategoriesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/forum_monster/templates/controllers/categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/generators/forum_monster/templates/controllers/categories_controller.rb', line 10

def create
  @category = Category.new(params[:category])
  
  if @category.save
    flash[:notice] = "Category was successfully created."
    redirect_to forums_url
  else
    render :action => 'new'
  end
end

#destroyObject



34
35
36
37
38
39
40
41
# File 'lib/generators/forum_monster/templates/controllers/categories_controller.rb', line 34

def destroy
  @category = Category.find(params[:id])
  
  if @category.destroy
    flash[:notice] = "Category was deleted."
    redirect_to forums_url
  end
end

#editObject



21
22
23
# File 'lib/generators/forum_monster/templates/controllers/categories_controller.rb', line 21

def edit
  @category = Category.find(params[:id])
end

#indexObject



2
3
4
# File 'lib/generators/forum_monster/templates/controllers/categories_controller.rb', line 2

def index
  @categories = Category.all
end

#newObject



6
7
8
# File 'lib/generators/forum_monster/templates/controllers/categories_controller.rb', line 6

def new
  @category = Category.new
end

#updateObject



25
26
27
28
29
30
31
32
# File 'lib/generators/forum_monster/templates/controllers/categories_controller.rb', line 25

def update
  @category = Category.find(params[:id])
  
  if @category.update_attributes(params[:category])
    flash[:notice] = "Category was updated successfully."
    redirect_to forums_url
  end
end