Sha256: fe1472f404a770b66c333bc2b694afc1b92d0cce5e78ba30265548eda36b4f29
Contents?: true
Size: 1.9 KB
Versions: 8
Compression:
Stored size: 1.9 KB
Contents
class CmsAdmin::PagesController < CmsAdmin::BaseController before_filter :build_cms_page, :only => [:new, :create] before_filter :build_upload_file, :only => [:new, :edit] before_filter :load_cms_page, :only => [:edit, :update, :destroy] def index return redirect_to :action => :new if @cms_site.cms_pages.count == 0 @cms_pages = [@cms_site.cms_pages.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 = @cms_site.cms_pages.find_by_id(params[:id]) || CmsPage.new @cms_page.cms_layout = @cms_site.cms_layouts.find_by_id(params[:layout_id]) end protected def build_cms_page @cms_page = @cms_site.cms_pages.new(params[:cms_page]) @cms_page.parent ||= (CmsPage.find_by_id(params[:parent_id]) || @cms_site.cms_pages.root) @cms_page.cms_layout ||= (@cms_page.parent && @cms_page.parent.cms_layout || @cms_site.cms_layouts.first) end def build_upload_file @upload = CmsUpload.new end def load_cms_page @cms_page = @cms_site.cms_pages.find(params[:id]) @cms_page.cms_layout ||= (@cms_page.parent && @cms_page.parent.cms_layout || @cms_site.cms_layouts.first) rescue ActiveRecord::RecordNotFound flash[:error] = 'Page not found' redirect_to :action => :index end end
Version data entries
8 entries across 8 versions & 1 rubygems