Sha256: 4bf4e38f5caf406dbb4d9cec96db44cdee6b042825bd06345bd2f39fa97f886a
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
class CmsAdmin::PagesController < CmsAdmin::BaseController before_filter :build_cms_page, :only => [:new, :create] before_filter :load_cms_page, :only => [:edit, :update, :destroy] def index @cms_pages = [CmsPage.root].compact end def new render end def edit render end def create @cms_page.save! flash[:notice] = 'Page saved' redirect_to :action => :edit, :id => @cms_page rescue ActiveRecord::RecordInvalid flash.now[:error] = 'Failed to create page' render :action => :new end def update @cms_page.update_attributes!(params[:cms_page]) flash[:notice] = 'Page updated' redirect_to :action => :edit, :id => @cms_page rescue ActiveRecord::RecordInvalid flash.now[:error] = 'Failed to update page' render :action => :edit end def destroy @cms_page.destroy flash[:notice] = 'Page deleted' redirect_to :action => :index end def form_blocks @cms_page = CmsPage.find_by_id(params[:id]) || CmsPage.new @cms_page.cms_layout = CmsLayout.find_by_id(params[:layout_id]) end protected def build_cms_page @cms_page = CmsPage.new(params[:cms_page]) @cms_page.parent ||= (CmsPage.find_by_id(params[:parent_id]) || CmsPage.root) @cms_page.cms_layout ||= (@cms_page.parent && @cms_page.parent.cms_layout || CmsLayout.first) end def load_cms_page @cms_page = CmsPage.find(params[:id]) @cms_page.cms_layout ||= (@cms_page.parent && @cms_page.parent.cms_layout || CmsLayout.first) rescue ActiveRecord::RecordNotFound flash[:error] = 'Page not found' redirect_to :action => :index end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
comfortable_mexican_sofa-1.0.1 | app/controllers/cms_admin/pages_controller.rb |
comfortable_mexican_sofa-1.0.0 | app/controllers/cms_admin/pages_controller.rb |