Class: Admin::SectionsController
- Defined in:
- app/controllers/admin/sections_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
- #update_all ⇒ Object
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/admin/sections_controller.rb', line 16 def create @section = @site.sections.build params[:section] if @section.save flash[:notice] = t(:'adva.sections.flash.create.success') redirect_to (params[:commit] == t(:'adva.sections.links.save_and_create_new') ? [:new, :admin, @site, :section] : [:admin, @site, @section, :articles]) else flash.now[:error] = t(:'adva.sections.flash.update.failure') render :action => "new" end end |
#destroy ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/admin/sections_controller.rb', line 42 def destroy if @section.destroy flash[:notice] = t(:'adva.sections.flash.destroy.success') redirect_to [:new, :admin, @site, :section] else flash.now[:error] = t(:'adva.sections.flash.destroy.failure') render :action => 'edit' end end |
#edit ⇒ Object
29 30 |
# File 'app/controllers/admin/sections_controller.rb', line 29 def edit end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/admin/sections_controller.rb', line 8 def index @sections = @site.sections end |
#new ⇒ Object
12 13 14 |
# File 'app/controllers/admin/sections_controller.rb', line 12 def new @section = @site.sections.build(:type => Section.types.first) end |
#update ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/admin/sections_controller.rb', line 32 def update if @section.update_attributes params[:section] flash[:notice] = t(:'adva.sections.flash.update.success') redirect_to [:edit, :admin, @site, @section] else flash.now[:error] = t(:'adva.sections.flash.update.failure') render :action => 'edit' end end |
#update_all ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/admin/sections_controller.rb', line 52 def update_all params[:sections].each do |id, attrs| section = Section.find id if attrs[:parent_id].nil? section.move_to_root else section.move_to_child_of attrs[:parent_id] end section.move_to_right_of attrs[:left_id] if attrs[:left_id] end render :text => 'OK' end |