From 55346ef5b46f80e37c930f2c6a3b214e7099e901 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Mon, 1 Sep 2014 23:48:55 +0300 Subject: [PATCH] Fix an annoying bug with devise and localization Preserve locale on redirect to the sign in page --- app/controllers/application_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ce2859d..a837781 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,11 +5,11 @@ class ApplicationController < ActionController::Base before_filter :configure_permitted_parameters, if: :devise_controller? before_action :set_locale - def default_url_options(options={}) - if params[:locale] - {locale: I18n.locale} + def self.default_url_options(options={}) + if I18n.locale != I18n.default_locale + options.merge({locale: I18n.locale}) else - {} + options end end