Sha256: 02d68b7c97842ee84c11db9ba8ba40c036ce4388cadfbe3ffe7126b750e739ad

Contents?: true

Size: 876 Bytes

Versions: 9

Compression:

Stored size: 876 Bytes

Contents

class Comfy::Cms::BaseController < ApplicationController
  
  before_action :load_cms_site
  
protected

  def load_cms_site
    @cms_site ||= if params[:site_id]
      ::Comfy::Cms::Site.find_by_id(params[:site_id])
    else
      ::Comfy::Cms::Site.find_site(request.host_with_port.downcase, request.fullpath)
    end
    
    if @cms_site
      if @cms_site.path.present? && !params[:site_id]
        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

9 entries across 9 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.12.8 app/controllers/comfy/cms/base_controller.rb
comfortable_mexican_sofa-1.12.7 app/controllers/comfy/cms/base_controller.rb
comfortable_mexican_sofa-1.12.6 app/controllers/comfy/cms/base_controller.rb
comfortable_mexican_sofa-1.12.5 app/controllers/comfy/cms/base_controller.rb
comfortable_mexican_sofa-1.12.4 app/controllers/comfy/cms/base_controller.rb
comfortable_mexican_sofa-1.12.3 app/controllers/comfy/cms/base_controller.rb
comfortable_mexican_sofa-1.12.2 app/controllers/comfy/cms/base_controller.rb
comfortable_mexican_sofa-1.12.1 app/controllers/comfy/cms/base_controller.rb
comfortable_mexican_sofa-1.12.0 app/controllers/comfy/cms/base_controller.rb