Sha256: e8434f5ee1a4e28655c6329d727d4396faa233a97699d526354291615b14d154

Contents?: true

Size: 991 Bytes

Versions: 19

Compression:

Stored size: 991 Bytes

Contents

# frozen_string_literal: true

module PagesCore
  class BaseController < ActionController::Base
    include PagesCore::Authentication
    include PagesCore::ErrorRenderer
    include PagesCore::ErrorReporting
    include PagesCore::ProcessTitler
    include PagesCore::PoliciesHelper
    include PagesCore::StaticCacheController

    before_action :set_locale
    after_action :set_content_language_header

    protected

    def append_info_to_payload(payload)
      super
      payload[:remote_ip] = request.remote_ip
      payload.merge!(current_user_context)
    end

    # Sets @locale from params[:locale], with I18n.default_locale as fallback
    def set_locale
      legacy_locales = { "nor" => "nb", "eng" => "en" }
      @locale = params[:locale] || I18n.default_locale.to_s
      @locale = legacy_locales[@locale] if legacy_locales[@locale]
    end

    def set_content_language_header
      return unless locale

      headers["Content-Language"] = locale.to_s
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
pages_core-3.12.4 app/controllers/pages_core/base_controller.rb
pages_core-3.12.3 app/controllers/pages_core/base_controller.rb
pages_core-3.12.2 app/controllers/pages_core/base_controller.rb
pages_core-3.12.1 app/controllers/pages_core/base_controller.rb
pages_core-3.12.0 app/controllers/pages_core/base_controller.rb
pages_core-3.11.3 app/controllers/pages_core/base_controller.rb
pages_core-3.11.2 app/controllers/pages_core/base_controller.rb
pages_core-3.11.1 app/controllers/pages_core/base_controller.rb
pages_core-3.11.0 app/controllers/pages_core/base_controller.rb
pages_core-3.10.2 app/controllers/pages_core/base_controller.rb
pages_core-3.10.1 app/controllers/pages_core/base_controller.rb
pages_core-3.9.2 app/controllers/pages_core/base_controller.rb
pages_core-3.9.1 app/controllers/pages_core/base_controller.rb
pages_core-3.9.0 app/controllers/pages_core/base_controller.rb
pages_core-3.8.3 app/controllers/pages_core/base_controller.rb
pages_core-3.8.2 app/controllers/pages_core/base_controller.rb
pages_core-3.8.1 app/controllers/pages_core/base_controller.rb
pages_core-3.8.0 app/controllers/pages_core/base_controller.rb
pages_core-3.7.0 app/controllers/pages_core/base_controller.rb