Sha256: 76f79d21e0f6bf2ae8bead086ab25c5e6a83314bc76b7cb8da16bade96327916
Contents?: true
Size: 1.33 KB
Versions: 8
Compression:
Stored size: 1.33 KB
Contents
class CmsAdmin::LayoutsController < CmsAdmin::BaseController before_filter :build_cms_layout, :only => [:new, :create] before_filter :load_cms_layout, :only => [:edit, :update, :destroy] def index @cms_layouts = @cms_site.cms_layouts.roots end def new render end def edit render end def create @cms_layout.save! flash[:notice] = 'Layout created' redirect_to :action => :edit, :id => @cms_layout rescue ActiveRecord::RecordInvalid flash.now[:error] = 'Failed to create layout' render :action => :new end def update @cms_layout.update_attributes!(params[:cms_layout]) flash[:notice] = 'Layout updated' redirect_to :action => :edit, :id => @cms_layout rescue ActiveRecord::RecordInvalid flash.now[:error] = 'Failed to update layout' render :action => :edit end def destroy @cms_layout.destroy flash[:notice] = 'Layout deleted' redirect_to :action => :index end protected def build_cms_layout @cms_layout = @cms_site.cms_layouts.new(params[:cms_layout]) @cms_layout.parent ||= CmsLayout.find_by_id(params[:parent_id]) end def load_cms_layout @cms_layout = @cms_site.cms_layouts.find(params[:id]) rescue ActiveRecord::RecordNotFound flash[:error] = 'Layout not found' redirect_to :action => :index end end
Version data entries
8 entries across 8 versions & 1 rubygems