Sha256: 0f3baf9c18a2943641f59c9126da04a69e1fe0c6aead406d3d32d27dd65d8113

Contents?: true

Size: 1.44 KB

Versions: 39

Compression:

Stored size: 1.44 KB

Contents

class CmsAdmin::SitesController < CmsAdmin::BaseController

  skip_before_filter  :load_admin_site,
                      :load_fixtures

  before_filter :build_site,  :only => [:new, :create]
  before_filter :load_site,   :only => [:edit, :update, :destroy]

  def index
    return redirect_to :action => :new if Cms::Site.count == 0
    @sites = Cms::Site.all
  end

  def new
    render
  end

  def edit
    render
  end

  def create
    @site.save!
    flash[:notice] = I18n.t('cms.sites.created')
    redirect_to cms_admin_site_layouts_path(@site)
  rescue ActiveRecord::RecordInvalid
    flash.now[:error] = I18n.t('cms.sites.creation_failure')
    render :action => :new
  end

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

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

protected

  def build_site
    @site = Cms::Site.new(params[:site])
    @site.hostname ||= request.host.downcase
  end

  def load_site
    @site = Cms::Site.find(params[:id])
    I18n.locale = ComfortableMexicanSofa.config.admin_locale || @site.locale
  rescue ActiveRecord::RecordNotFound
    flash[:error] = I18n.t('cms.sites.not_found')
    redirect_to :action => :index
  end

end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.5.8 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.5.7 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.5.6 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.5.5 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.5.4 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.5.3 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.5.2 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.5.1 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.5.0 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.4.22 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.4.21 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.4.20 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.4.19 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.4.18 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.4.17 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.4.16 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.4.15 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.4.14 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.4.13 app/controllers/cms_admin/sites_controller.rb
comfortable_mexican_sofa-1.4.12 app/controllers/cms_admin/sites_controller.rb