Class: 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 20 |
# File 'app/controllers/admin/page/categories_controller.rb', line 11 def create @category = @section.categories.build params[:category] if @category.save flash[:notice] = t(:'adva.categories.flash.create.success') redirect_to [:admin, @section, :categories] else flash.now[:error] = t(:'adva.categories.flash.create.failure') + current_resource_errors render :action => "new" end end |
#destroy ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/admin/page/categories_controller.rb', line 41 def destroy if @category.destroy flash[:notice] = t(:'adva.categories.flash.destroy.success') redirect_to [:admin, @section, :categories] else flash.now[:error] = t(:'adva.categories.flash.destroy.failure') + 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
22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/admin/page/categories_controller.rb', line 22 def update if @category.update params[:category] flash[:notice] = t(:'adva.categories.flash.update.success') redirect_to [:admin, @section, :categories] else flash.now[:error] = t(:'adva.categories.flash.update.failure') + current_resource_errors render :action => 'edit' end end |
#update_all ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'app/controllers/admin/page/categories_controller.rb', line 32 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 |