Sha256: 351f78d9e2bdea464526884a751f216b0257b392a7a8facd05fc5710a6396851

Contents?: true

Size: 834 Bytes

Versions: 7

Compression:

Stored size: 834 Bytes

Contents

class Cms::BaseController < ApplicationController
  
  before_action :load_cms_site
  
protected

  def load_cms_site
    @cms_site ||= if params[:site_id]
      ::Cms::Site.find_by_id(params[:site_id])
    else
      ::Cms::Site.find_site(request.host_with_port.downcase, request.fullpath)
    end
    
    if @cms_site
      if @cms_site.path.present?
        if params[:cms_path] && params[:cms_path].match(/\A#{@cms_site.path}/)
          params[:cms_path].gsub!(/\A#{@cms_site.path}/, '')
          params[:cms_path] && params[:cms_path].gsub!(/\A\//, '')
        else
          raise ActionController::RoutingError.new('Site Not Found')
        end
      end
      I18n.locale = @cms_site.locale
    else
      I18n.locale = I18n.default_locale
      raise ActionController::RoutingError.new('Site Not Found')
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.11.2 app/controllers/cms/base_controller.rb
comfortable_mexican_sofa-1.11.1 app/controllers/cms/base_controller.rb
comfortable_mexican_sofa-1.11.0 app/controllers/cms/base_controller.rb
comfortable_mexican_sofa-1.10.3 app/controllers/cms/base_controller.rb
comfortable_mexican_sofa-1.10.2 app/controllers/cms/base_controller.rb
comfortable_mexican_sofa-1.10.1 app/controllers/cms/base_controller.rb
comfortable_mexican_sofa-1.10.0 app/controllers/cms/base_controller.rb