Sha256: 43ccab87984dcbb6ed9ebb4430b7548ee93c6cf73a53d4dd1bd841b9506f522c

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

# encoding: utf-8

# Abstract controller for all frontend controllers.
module PagesCore
  class FrontendController < ::ApplicationController
    include ApplicationHelper

    before_action :set_i18n_locale

    # Loads @root_pages and @rss_feeds. To automatically load these in your
    # own controllers, add the following line to your controller definition:
    #
    #   before_action :load_root_pages
    #
    def load_root_pages
      @root_pages = Page.roots.localized(@locale).published
      @rss_feeds = Page.where(feed_enabled: true).localized(@locale).published
    end

    private

    def set_i18n_locale
      legacy_locales = {
        "nor" => "nb",
        "eng" => "en"
      }
      locale_param = params[:locale] || I18n.default_locale
      if legacy_locales[locale_param]
        locale_param = legacy_locales[locale_param]
      end
      I18n.locale = locale_param
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pages_core-3.4.3 app/controllers/pages_core/frontend_controller.rb