Class: PandaCms::Admin::PagesController
- Inherits:
-
PandaCms::ApplicationController
- Object
- ActionController::Base
- PandaCms::ApplicationController
- PandaCms::Admin::PagesController
- Defined in:
- app/controllers/panda_cms/admin/pages_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /admin/pages.
-
#edit ⇒ Object
Loads the page editor.
-
#index ⇒ Object
Lists all pages which can be managed by the administrator.
-
#new ⇒ Object
Loads the add page form.
- #update ⇒ Object
Methods inherited from PandaCms::ApplicationController
#add_breadcrumb, #authenticate_admin_user!, #authenticate_user!, #breadcrumbs, #current_user, #set_current_request_details, #user_signed_in?
Methods included from PandaCms::ApplicationHelper
#active_link?, #block_link_to, #component, #level_indent, #menu_indent, #nav_class, #nav_highlight_colour_classes, #panda_cms_editor, #panda_cms_form_with, #selected_nav_highlight_colour_classes, #table_indent, #title_tag
Instance Method Details
#create ⇒ Object
POST /admin/pages
34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/panda_cms/admin/pages_controller.rb', line 34 def create page = PandaCms::Page.new(page_params) if page.save page.update(path: page.parent.path + page.path) unless page.parent.path == "/" redirect_to edit_admin_page_path(page), notice: "The page was successfully created." else flash[:error] = "There was an error creating the page." locals = setup_new_page_form(page: page) render :new, locals: locals, status: :unprocessable_entity end end |
#edit ⇒ Object
Loads the page editor
27 28 29 30 31 |
# File 'app/controllers/panda_cms/admin/pages_controller.rb', line 27 def edit page.title, edit_admin_page_path(page) render :edit, locals: {page: page, template: page.template} end |
#index ⇒ Object
Lists all pages which can be managed by the administrator
13 14 15 16 |
# File 'app/controllers/panda_cms/admin/pages_controller.rb', line 13 def index homepage = PandaCms::Page.find_by(path: "/") render :index, locals: {root_page: homepage} end |
#new ⇒ Object
Loads the add page form
20 21 22 23 |
# File 'app/controllers/panda_cms/admin/pages_controller.rb', line 20 def new locals = setup_new_page_form(page: page) render :new, locals: locals end |
#update ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/panda_cms/admin/pages_controller.rb', line 48 def update if page.update(page_params) redirect_to edit_admin_page_path(page), status: :see_other, flash: {success: "This page was successfully updated!"} else flash[:error] = "There was an error updating the page." render :edit, status: :unprocessable_entity end end |