Sha256: 72a86b662c211b22ffde9a88194fb6c708f366f0cd2dad9c5aad17a17898d58e

Contents?: true

Size: 791 Bytes

Versions: 3

Compression:

Stored size: 791 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
    else
      raise ActionController::RoutingError.new('Site Not Found')
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-2.0.2 app/controllers/comfy/cms/base_controller.rb
comfortable_mexican_sofa-2.0.1 app/controllers/comfy/cms/base_controller.rb
comfortable_mexican_sofa-2.0.0 app/controllers/comfy/cms/base_controller.rb