Class: Admin::Page::CategoriesController
- Inherits:
-
BaseController
- Object
- BaseController
- Admin::Page::CategoriesController
- Defined in:
- app/controllers/admin/page/categories_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
- #update_all ⇒ Object
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/admin/page/categories_controller.rb', line 11 def create @category = @section.categories.build params[:category] if @category.save redirect_to [:admin, @section, :categories], notice: "The category has been created." else flash.now.alert = "The category could not be created." + current_resource_errors render :action => "new" end end |
#destroy ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'app/controllers/admin/page/categories_controller.rb', line 39 def destroy if @category.destroy redirect_to [:admin, @section, :categories], notice: "The category has been deleted." else flash.now.alert = "The category could not be deleted." + current_resource_errors render :action => 'edit' end end |
#index ⇒ Object
4 5 |
# File 'app/controllers/admin/page/categories_controller.rb', line 4 def index end |
#new ⇒ Object
7 8 9 |
# File 'app/controllers/admin/page/categories_controller.rb', line 7 def new @category = @section.categories.build end |
#update ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/controllers/admin/page/categories_controller.rb', line 21 def update if @category.update params[:category] redirect_to [:admin, @section, :categories], notice: "The category has been updated." else flash.now.alert = "The category could not be updated." + current_resource_errors render :action => 'edit' end end |
#update_all ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'app/controllers/admin/page/categories_controller.rb', line 30 def update_all # FIXME we currently use :update_all to update the position for a single object # instead we should either use :update_all to batch update all objects on this # resource or use :update. applies to articles, sections, categories etc. @section.categories.update(params[:categories].keys, params[:categories].values) @section.categories.update_paths! render :text => 'OK' end |