0
0
Fork 0

Add user locale setting

This commit is contained in:
Eugen Rochko 2016-11-16 17:51:02 +01:00
parent 01e43c3e57
commit 2c766bd4b4
10 changed files with 49 additions and 13 deletions

View file

@ -13,6 +13,7 @@ class ApplicationController < ActionController::Base
rescue_from ActiveRecord::RecordNotFound, with: :not_found
before_action :store_current_location, except: :raise_not_found, unless: :devise_controller?
before_action :set_locale, if: 'user_signed_in?'
def raise_not_found
raise ActionController::RoutingError, "No route matches #{params[:unmatched_route]}"
@ -24,6 +25,12 @@ class ApplicationController < ActionController::Base
store_location_for(:user, request.url)
end
def set_locale
I18n.locale = current_user.locale || I18n.default_locale
rescue I18n::InvalidLocale
I18n.locale = I18n.default_locale
end
protected
def not_found