Module: RailsCommonController
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/controllers/concerns/rails_common_controller.rb
Instance Method Summary collapse
Instance Method Details
#set_country ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/concerns/rails_common_controller.rb', line 36 def set_country if params[:country] session[:country] = params[:country] elsif current_user session[:country] = current_user.country end logger.debug " ==========> Country: #{session[:country]}" end |
#set_locale ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/concerns/rails_common_controller.rb', line 24 def set_locale if params[:locale] session[:locale] = params[:locale] end I18n.locale = session[:locale] || I18n.default_locale if current_user && current_user.locale.to_s != session[:locale].to_s current_user.update locale: session[:locale] end logger.debug " ==========> Locale: #{I18n.locale}" end |
#set_timezone ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/concerns/rails_common_controller.rb', line 9 def set_timezone if session[:zone] Time.zone = session[:zone] elsif request.headers['HTTP_UTC_OFFSET'].present? zone = -(request.headers['HTTP_UTC_OFFSET'].to_i / 60) Time.zone = zone session[:zone] = zone end if current_user && current_user.timezone.blank? current_user.update timezone: Time.zone.name end logger.debug " ==========> Zone: #{Time.zone}" end |