Class: Guts::CategoriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Guts::CategoriesController
- Defined in:
- app/controllers/guts/categories_controller.rb
Overview
Categories controller
Instance Method Summary collapse
-
#create ⇒ Object
Creates a category through post.
-
#destroy ⇒ Object
Destroys a category.
-
#edit ⇒ Object
Editing for a category.
-
#index ⇒ Object
Displays a list of categories.
-
#new ⇒ Object
Creation of a new category.
-
#show ⇒ Object
Shows details about a single category.
-
#update ⇒ Object
Updates a category through patch.
Methods included from MultisiteConcern
#current_site, #with_current_site
Methods included from SessionsHelper
#current_user, #log_in, #log_out, #logged_in?
Instance Method Details
#create ⇒ Object
Note:
Redirects to #index if successfull or re-renders #new if not
Creates a category through post
28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/guts/categories_controller.rb', line 28 def create @category = Category.new category_params if @category.save flash[:notice] = 'Category was successfully created.' redirect_to categories_path else render :new end end |
#destroy ⇒ Object
Note:
Redirects to #index on success
Destroys a category
52 53 54 55 56 57 |
# File 'app/controllers/guts/categories_controller.rb', line 52 def destroy @category.destroy flash[:notice] = 'Category was successfully destroyed.' redirect_to categories_path end |
#edit ⇒ Object
Editing for a category
23 24 |
# File 'app/controllers/guts/categories_controller.rb', line 23 def edit end |
#index ⇒ Object
Displays a list of categories
9 10 11 |
# File 'app/controllers/guts/categories_controller.rb', line 9 def index @categories = Category.all end |
#new ⇒ Object
Creation of a new category
18 19 20 |
# File 'app/controllers/guts/categories_controller.rb', line 18 def new @category = Category.new end |
#show ⇒ Object
Shows details about a single category
14 15 |
# File 'app/controllers/guts/categories_controller.rb', line 14 def show end |
#update ⇒ Object
Note:
Redirects to #index if successfull or re-renders #edit if not
Updates a category through patch
41 42 43 44 45 46 47 48 |
# File 'app/controllers/guts/categories_controller.rb', line 41 def update if @category.update category_params flash[:notice] = 'Category was successfully updated.' redirect_to categories_path else render :edit end end |