Sha256: 00bb533fa1a8e04b281352b756e1a567659706feb878dc1c90f6db41ed216811

Contents?: true

Size: 792 Bytes

Versions: 13

Compression:

Stored size: 792 Bytes

Contents

module Locomotive
  module Concerns
    module SiteDispatcherController

      extend ActiveSupport::Concern

      included do
        if self.respond_to?(:before_action)
          helper_method :current_site
        end
      end

      protected

      def current_site
        @current_site ||= request.env['locomotive.site']
      end

      def current_site?
        !current_site.nil?
      end

      def require_site
        return true if current_site?

        render_no_site_error
      end

      def render_no_site_error
        respond_to do |format|
          format.html do
            redirect_to sites_path
          end
          format.json do
            render json: { error: 'No site found' }, status: :not_found
          end
        end
      end

    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
locomotivecms-4.1.1 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-4.1.0 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-4.1.0.rc1 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-4.0.3 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-4.0.2 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-4.0.1 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-4.0.0 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-4.0.0.rc0 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-4.0.0.alpha3 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.4.1 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-4.0.0.alpha2 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-4.0.0.alpha1 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.4.0 app/controllers/locomotive/concerns/site_dispatcher_controller.rb