Class: Admin::SectionsController
- Inherits:
-
BaseController
- Object
- BaseController
- 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 = "The section has been created." redirect_to (params[:commit] == "Save and create another section" ? [:new, :admin, :section] : [:admin, @section, :articles]) else flash.now.alert = "The section could not be created." render :action => "new" end end |
#destroy ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'app/controllers/admin/sections_controller.rb', line 40 def destroy if @section.destroy redirect_to [:new, :admin, :section], notice: "The section has been deleted." else flash.now.alert = "The section could not be deleted." 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 |
# File 'app/controllers/admin/sections_controller.rb', line 31 def update if @section.update params[:section] redirect_to [:edit, :admin, @section], notice: "The section has been updated." else flash.now.alert = "The section could not be updated." render :action => 'edit' end end |
#update_all ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/admin/sections_controller.rb', line 49 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 |