Class: Blogr::CategoriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Blogr::CategoriesController
- Defined in:
- app/controllers/blogr/categories_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/blogr/categories_controller.rb', line 25 def create @category = Category.new(category_params) if @category.save redirect_to category_path(@category), notice: 'Category was successfully created.' else render action: 'new' end end |
#destroy ⇒ Object
43 44 45 46 |
# File 'app/controllers/blogr/categories_controller.rb', line 43 def destroy @category.destroy redirect_to categories_url, notice: 'Category was successfully destroyed.' end |
#edit ⇒ Object
21 22 23 |
# File 'app/controllers/blogr/categories_controller.rb', line 21 def edit @title = "Editing '#{@category.title}'" end |
#index ⇒ Object
7 8 9 10 |
# File 'app/controllers/blogr/categories_controller.rb', line 7 def index @categories = Category.all @title = "Categories" end |
#new ⇒ Object
16 17 18 19 |
# File 'app/controllers/blogr/categories_controller.rb', line 16 def new @category = Category.new @title = "New Category" end |
#show ⇒ Object
12 13 14 |
# File 'app/controllers/blogr/categories_controller.rb', line 12 def show @title = @category.title end |
#update ⇒ Object
35 36 37 38 39 40 41 |
# File 'app/controllers/blogr/categories_controller.rb', line 35 def update if @category.update(category_params) redirect_to category_path(@category), notice: 'Category was successfully updated.' else render action: 'edit' end end |