Class: Cms::Admin::PagesController
- Inherits:
-
AdminController
- Object
- AdminController
- Cms::Admin::PagesController
- Defined in:
- app/controllers/cms/admin/pages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
- #update_page_tree ⇒ Object
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/cms/admin/pages_controller.rb', line 17 def create @page = Page.new(params[:page]) @pages = Page.ordered if @page.save flash[:notice] = t('cms.admin.pages.flash_create') redirect_to(cms_admin_pages_path) else render :action => "new" end end |
#destroy ⇒ Object
41 42 43 44 45 46 |
# File 'app/controllers/cms/admin/pages_controller.rb', line 41 def destroy @page = Page.find(params[:id]) @page.destroy flash[:notice] = @page ? @page.errors.on_base : flash[:notice] = t('cms.admin.pages.flash_delete') redirect_to(cms_admin_pages_path) end |
#edit ⇒ Object
12 13 14 15 |
# File 'app/controllers/cms/admin/pages_controller.rb', line 12 def edit @page = Page.find(params[:id]) @pages = Page.ordered end |
#index ⇒ Object
3 4 5 |
# File 'app/controllers/cms/admin/pages_controller.rb', line 3 def index @pages = Page.ordered end |
#new ⇒ Object
7 8 9 10 |
# File 'app/controllers/cms/admin/pages_controller.rb', line 7 def new @page = Page.new @pages = Page.ordered end |
#update ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/cms/admin/pages_controller.rb', line 29 def update @page = Page.find(params[:id]) @pages = Page.ordered if @page.update_attributes(params[:page]) flash[:notice] = t('cms.admin.pages.flash_update') redirect_to( cms_admin_pages_path ) else render :action => "edit" end end |
#update_page_tree ⇒ Object
48 49 50 51 52 53 54 |
# File 'app/controllers/cms/admin/pages_controller.rb', line 48 def update_page_tree position = -1 params[:tree_root].sort.each do |id, pos| save_tree params[:tree_root][id], nil, position += 1 end render :nothing => true end |