Class: Cms::PagesController
- Inherits:
-
BaseController
- Object
- ApplicationController
- ApplicationController
- BaseController
- Cms::PagesController
- Includes:
- PublishWorkflow
- Defined in:
- app/controllers/cms/pages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #new ⇒ Object
- #resource ⇒ Object
- #resource_param ⇒ Object
- #revert_to ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #version ⇒ Object
Methods inherited from BaseController
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/cms/pages_controller.rb', line 34 def create @page = Page.new(page_params) @page.section = @section if @page.save flash[:notice] = "Page was '#{@page.name}' created." redirect_to @page else render :action => "new" end end |
#destroy ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/cms/pages_controller.rb', line 57 def destroy respond_to do |format| if @page.destroy = "Page '#{@page.name}' was deleted." format.html { flash[:notice] = ; redirect_to(sitemap_url) } format.json { render :json => {:success => true, :message => } } else = "Page '#{@page.name}' could not be deleted" format.html { flash[:error] = ; redirect_to(sitemap_url) } format.json { render :json => {:success => false, :message => } } end end end |
#new ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/controllers/cms/pages_controller.rb', line 22 def new @page = Page.new(:section => @section, :cacheable => true) if @section.child_nodes.count < 1 @page.name = "Overview" @page.path = @section.path end end |
#resource ⇒ Object
14 15 16 |
# File 'app/controllers/cms/pages_controller.rb', line 14 def resource @page end |
#resource_param ⇒ Object
18 19 20 |
# File 'app/controllers/cms/pages_controller.rb', line 18 def resource_param :page end |
#revert_to ⇒ Object
99 100 101 102 103 104 105 106 107 108 |
# File 'app/controllers/cms/pages_controller.rb', line 99 def revert_to if @page.revert_to(params[:version]) flash[:notice] = "Page '#{@page.name}' was reverted to version #{params[:version]}" end respond_to do |format| format.html { redirect_to @page.path } format.js { render :template => 'cms/shared/show_notice' } end end |
#show ⇒ Object
30 31 32 |
# File 'app/controllers/cms/pages_controller.rb', line 30 def show redirect_to Page.find(params[:id]).path end |
#update ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/cms/pages_controller.rb', line 45 def update if @page.update(page_params) flash[:notice] = "Page was '#{@page.name}' updated." redirect_to @page else render :action => "edit" end rescue ActiveRecord::StaleObjectError => e @other_version = @page.class.find(@page.id) render :action => "edit" end |
#version ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'app/controllers/cms/pages_controller.rb', line 90 def version @page = @page.as_of_version(params[:version]) @show_toolbar = true @show_page_toolbar = true @_connectors = @page.current_connectors @_connectables = @page.contents render :layout => @page.layout, :template => 'cms/content/show' end |