Class: Railspress::Admin::CategoriesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Railspress::Admin::CategoriesController
- Defined in:
- app/controllers/railspress/admin/categories_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'app/controllers/railspress/admin/categories_controller.rb', line 14 def create @category = Category.new(category_params) if @category.save redirect_to admin_categories_path, notice: "Category created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
34 35 36 37 38 39 40 |
# File 'app/controllers/railspress/admin/categories_controller.rb', line 34 def destroy if @category.destroy redirect_to admin_categories_path, notice: "Category deleted." else redirect_to admin_categories_path, alert: "Cannot delete category with posts." end end |
#edit ⇒ Object
23 24 |
# File 'app/controllers/railspress/admin/categories_controller.rb', line 23 def edit end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/railspress/admin/categories_controller.rb', line 6 def index @categories = Category.ordered end |
#new ⇒ Object
10 11 12 |
# File 'app/controllers/railspress/admin/categories_controller.rb', line 10 def new @category = Category.new end |
#update ⇒ Object
26 27 28 29 30 31 32 |
# File 'app/controllers/railspress/admin/categories_controller.rb', line 26 def update if @category.update(category_params) redirect_to admin_categories_path, notice: "Category updated." else render :edit, status: :unprocessable_entity end end |