Sha256: dd47e7e8425abbf1e6090eec9f7fcd70814445c4f83e1a3bf13a5f2640d0926b

Contents?: true

Size: 883 Bytes

Versions: 3

Compression:

Stored size: 883 Bytes

Contents

module Qbrick
  module Cms
    class BackendController < ActionController::Base
      respond_to :html
      layout 'qbrick/cms/application'
      before_action :set_content_locale, :authenticate_admin!

      def set_content_locale
        # this was taken from: https://github.com/screenconcept/hieronymus_shop/pull/218/files
        # and needs further work:
        # TODO: document how to implement in frontend
        # TODO: implement frontend part in our rails_template
        # TODO: add specs
        new_locale = params[:content_locale] || session['backend_locale'] || I18n.locale
        session['backend_locale'] = new_locale.to_s
        return if I18n.locale == new_locale || !I18n.locale_available?(new_locale)
        I18n.locale = new_locale
      end

      def default_url_options
        { content_locale: I18n.locale }.merge(super)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qbrick-2.5.2 app/controllers/qbrick/cms/backend_controller.rb
qbrick-2.5.1 app/controllers/qbrick/cms/backend_controller.rb
qbrick-2.5.0 app/controllers/qbrick/cms/backend_controller.rb