Skip to content

Wrong locale gets randomly loaded #3140

Closed
@sedubois

Description

@sedubois

I have followed the instructions in #2837 (after bumping into the symptoms described in #3134) as follows:

# initializers/rails_admin.rb
RailsAdmin.config do |config|
  config.parent_controller = "Admin::BaseController"
end

# controllers/admin/base_controller.rb
class Admin::BaseController < ApplicationController
  ...
end

# controllers/application_controller.rb
class ApplicationController < ActionController::Base
  before_action :set_locale

  def set_locale
    
  def set_locale
    if [RailsAdmin].include?(self.class.parent)
      I18n.locale = :en
    else
      I18n.locale = get_locale_from_params || get_locale_from_user || get_locale_from_session || get_locale_from_accept || I18n.default_locale
      session[:locale] = I18n.locale
      current_user.update(locale: I18n.locale) if user_signed_in? and current_user.locale != I18n.locale
      I18n.locale
    end
  end
end

Nevertheless, the locale still randomly loads into French in RailsAdmin. Would you have any idea what I am missing? Thank you very much 🙏

Screenshot 2019-05-15 at 12 26 31

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions