Sha256: 8d08d498fe2f7b82585b5c15d627387bd2ca764e41da8f687dcd0d07db77703c

Contents?: true

Size: 1.42 KB

Versions: 32

Compression:

Stored size: 1.42 KB

Contents

class CmsAdmin::LayoutsController < CmsAdmin::BaseController

  before_filter :build_layout,  :only => [:new, :create]
  before_filter :load_layout,   :only => [:edit, :update, :destroy]

  def index
    return redirect_to :action => :new if @site.layouts.count == 0
    @layouts = @site.layouts.roots
  end

  def new
    render
  end

  def edit
    render
  end

  def create
    @layout.save!
    flash[:notice] = I18n.t('cms.layouts.created')
    redirect_to :action => :edit, :id => @layout
  rescue ActiveRecord::RecordInvalid
    flash.now[:error] = I18n.t('cms.layouts.creation_failure')
    render :action => :new
  end

  def update
    @layout.update_attributes!(params[:layout])
    flash[:notice] = I18n.t('cms.layouts.updated')
    redirect_to :action => :edit, :id => @layout
  rescue ActiveRecord::RecordInvalid
    flash.now[:error] = I18n.t('cms.layouts.update_failure')
    render :action => :edit
  end

  def destroy
    @layout.destroy
    flash[:notice] = I18n.t('cms.layouts.deleted')
    redirect_to :action => :index
  end

protected

  def build_layout
    @layout = @site.layouts.new(params[:layout])
    @layout.parent  ||= Cms::Layout.find_by_id(params[:parent_id])
    @layout.content ||= '{{ cms:page:content:text }}'
  end

  def load_layout
    @layout = @site.layouts.find(params[:id])
  rescue ActiveRecord::RecordNotFound
    flash[:error] = I18n.t('cms.layouts.not_found')
    redirect_to :action => :index
  end

end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.4.22 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.21 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.20 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.19 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.18 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.17 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.16 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.15 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.14 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.13 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.12 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.11 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.10 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.9 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.8 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.7 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.6 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.5 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.4 app/controllers/cms_admin/layouts_controller.rb
comfortable_mexican_sofa-1.4.3 app/controllers/cms_admin/layouts_controller.rb