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
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/admin/sections_controller.rb', line 15 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, :section] : [:admin, @section, :articles]) else flash.now[:error] = t(:'adva.sections.flash.update.failure') render :action => "new" end end |
#destroy ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/admin/sections_controller.rb', line 41 def destroy if @section.destroy flash[:notice] = t(:'adva.sections.flash.destroy.success') redirect_to [:new, :admin, :section] else flash.now[:error] = t(:'adva.sections.flash.destroy.failure') render :action => 'edit' end end |
#edit ⇒ Object
28 29 |
# File 'app/controllers/admin/sections_controller.rb', line 28 def edit end |
#index ⇒ Object
7 8 9 |
# File 'app/controllers/admin/sections_controller.rb', line 7 def index @sections = @site.sections end |
#new ⇒ Object
11 12 13 |
# File 'app/controllers/admin/sections_controller.rb', line 11 def new @section = @site.sections.build(:type => Section.types.first) end |
#update ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/admin/sections_controller.rb', line 31 def update if @section.update params[:section] flash[:notice] = t(:'adva.sections.flash.update.success') redirect_to [:edit, :admin, @section] else flash.now[:error] = t(:'adva.sections.flash.update.failure') render :action => 'edit' end end |
#update_all ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/admin/sections_controller.rb', line 51 def update_all params[:sections].each do |id, attrs| section = Section.find(id) parent = Section.find_by(id: attrs[:parent_id]) left = Section.find_by_id attrs[:left_id] if parent content.move_to_child_with_index parent, 0 else section.move_to_root section.move_to_left_of section.siblings.first end section.move_to_right_of left if left end head :ok end |