Sha256: 6b8b5f685537f6d00379921b021457253c893cbafe8806e52e13b26918bb3fb8

Contents?: true

Size: 792 Bytes

Versions: 19

Compression:

Stored size: 792 Bytes

Contents

module Locomotive
  module Concerns
    module SiteDispatcherController

      extend ActiveSupport::Concern

      included do
        if self.respond_to?(:before_filter)
          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

19 entries across 19 versions & 1 rubygems

Version Path
locomotivecms-3.3.0 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.3.0.rc3 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.3.0.rc2 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.1.2 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.2.1 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.3.0.rc1 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.2.0 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.2.0.rc2 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.2.0.rc1 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.1.1 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.1.0 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.1.0.rc3 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.1.0.rc2 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.1.0.rc1 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.0.1 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.0.0 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.0.0.rc7 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.0.0.rc6 app/controllers/locomotive/concerns/site_dispatcher_controller.rb
locomotivecms-3.0.0.rc5 app/controllers/locomotive/concerns/site_dispatcher_controller.rb