Sha256: f2b3942ce4d6f0127f470a8acd2e0c3ccf23ce43e91c4f88517c65bcd1306567

Contents?: true

Size: 869 Bytes

Versions: 12

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true

class Comfy::Cms::BaseController < ComfortableMexicanSofa.config.public_base_controller.to_s.constantize

  before_action :load_cms_site

  helper Comfy::CmsHelper

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]&.match(%r{\A#{@cms_site.path}})
          params[:cms_path].gsub!(%r{\A#{@cms_site.path}}, "")
          params[:cms_path]&.gsub!(%r{\A/}, "")
        else
          raise ActionController::RoutingError, "Site Not Found"
        end
      end
    else
      raise ActionController::RoutingError, "Site Not Found"
    end
  end

end

Version data entries

12 entries across 12 versions & 6 rubygems

Version Path
comfortable_mexican_sofa-2.0.19 app/controllers/comfy/cms/base_controller.rb
PixelForce_ETS-0.0.2 app/controllers/comfy/cms/base_controller.rb
PixelForce_ETS-0.0.1 app/controllers/comfy/cms/base_controller.rb
kcyEtsTest2-0.0.4 app/controllers/comfy/cms/base_controller.rb
kcyEtsTest2-0.0.3 app/controllers/comfy/cms/base_controller.rb
kcyEtsTest2-0.0.2 app/controllers/comfy/cms/base_controller.rb
kcyEtsTest2-0.0.1 app/controllers/comfy/cms/base_controller.rb
kcyEtsTest-0.0.1 app/controllers/comfy/cms/base_controller.rb
kcyEtsTest-2.2.19 app/controllers/comfy/cms/base_controller.rb
ComfortableMexicanSofa-2.0.18 app/controllers/comfy/cms/base_controller.rb
kcy1-1.0 app/controllers/comfy/cms/base_controller.rb
comfortable_mexican_sofa-2.0.18 app/controllers/comfy/cms/base_controller.rb