Class | Cms::PagesController |
In: |
app/controllers/cms/pages_controller.rb
|
Parent: | Cms::BaseController |
# File app/controllers/cms/pages_controller.rb, line 22 22: def create 23: @page = Page.new(params[:page]) 24: @page.section = @section 25: if @page.save 26: flash[:notice] = "Page was '#{@page.name}' created." 27: redirect_to [:cms, @page] 28: else 29: render :action => "new" 30: end 31: end
# File app/controllers/cms/pages_controller.rb, line 45 45: def destroy 46: respond_to do |format| 47: if @page.destroy 48: message = "Page '#{@page.name}' was deleted." 49: format.html { flash[:notice] = message; redirect_to(cms_sitemap_url) } 50: format.json { render :json => {:success => true, :message => message } } 51: else 52: message = "Page '#{@page.name}' could not be deleted" 53: format.html { flash[:error] = message; redirect_to(cms_sitemap_url) } 54: format.json { render :json => {:success => false, :message => message } } 55: end 56: end 57: end
# File app/controllers/cms/pages_controller.rb, line 10 10: def new 11: @page = Page.new(:section => @section, :cacheable => true) 12: if @section.child_nodes.count < 1 13: @page.name = "Overview" 14: @page.path = @section.path 15: end 16: end
# File app/controllers/cms/pages_controller.rb, line 85 85: def revert_to 86: if @page.revert_to(params[:version]) 87: flash[:notice] = "Page '#{@page.name}' was reverted to version #{params[:version]}" 88: end 89: 90: respond_to do |format| 91: format.html { redirect_to @page.path } 92: format.js { render :template => 'cms/shared/show_notice' } 93: end 94: end
# File app/controllers/cms/pages_controller.rb, line 18 18: def show 19: redirect_to Page.find(params[:id]).path 20: end
# File app/controllers/cms/pages_controller.rb, line 33 33: def update 34: if @page.update_attributes(params[:page]) 35: flash[:notice] = "Page was '#{@page.name}' updated." 36: redirect_to [:cms, @page] 37: else 38: render :action => "edit" 39: end 40: rescue ActiveRecord::StaleObjectError => e 41: @other_version = @page.class.find(@page.id) 42: render :action => "edit" 43: end