Sha256: 1b56ff03bb0425feb83ef3441d4b71b18741b31b4442ed5d78e19d2ab74ea2fd
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 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 = CmsLayout.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 = CmsLayout.new(params[:cms_layout]) @cms_layout.parent ||= CmsLayout.find_by_id(params[:parent_id]) end def load_cms_layout @cms_layout = CmsLayout.find(params[:id]) rescue ActiveRecord::RecordNotFound flash[:error] = 'Layout 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/layouts_controller.rb |
comfortable_mexican_sofa-1.0.0 | app/controllers/cms_admin/layouts_controller.rb |