Class: CategoriesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- CategoriesController
- Defined in:
- lib/generators/forum_monster/templates/controllers/categories_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
21 22 23 |
# File 'lib/generators/forum_monster/templates/controllers/categories_controller.rb', line 21 def edit @category = Category.find(params[:id]) end |
#index ⇒ Object
2 3 4 |
# File 'lib/generators/forum_monster/templates/controllers/categories_controller.rb', line 2 def index @categories = Category.all end |
#new ⇒ Object
6 7 8 |
# File 'lib/generators/forum_monster/templates/controllers/categories_controller.rb', line 6 def new @category = Category.new end |
#update ⇒ Object
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 |