Sha256: 513cf3e359089e0d296eae9d2c8d19a5a77b774a060988f9d5685898a74bd4e2

Contents?: true

Size: 584 Bytes

Versions: 13

Compression:

Stored size: 584 Bytes

Contents

module Locomotive
  module Concerns
    module RedirectToMainHostController

      extend ActiveSupport::Concern

      included do

        before_action :redirect_to_main_host

      end

      private

      def redirect_to_main_host
        return if Locomotive.config.host.blank? || request.env['locomotive.default_host'].present?

        if request.host != Locomotive.config.host
          options = { host: Locomotive.config.host }
          options[:port] = request.port if request.port != 80

          redirect_to root_url(options)
        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/redirect_to_main_host_controller.rb
locomotivecms-4.1.0 app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb
locomotivecms-4.1.0.rc1 app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb
locomotivecms-4.0.3 app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb
locomotivecms-4.0.2 app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb
locomotivecms-4.0.1 app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb
locomotivecms-4.0.0 app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb
locomotivecms-4.0.0.rc0 app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb
locomotivecms-4.0.0.alpha3 app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb
locomotivecms-3.4.1 app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb
locomotivecms-4.0.0.alpha2 app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb
locomotivecms-4.0.0.alpha1 app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb
locomotivecms-3.4.0 app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb