Class: InlineFormsApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
lib/app/controllers/inline_forms_application_controller.rb

Instance Method Summary collapse

Instance Method Details

#extract_locale_from_subdomainObject

Get locale code from request subdomain (like it.application.local:3000)



15
16
17
18
19
# File 'lib/app/controllers/inline_forms_application_controller.rb', line 15

def extract_locale_from_subdomain
  locale = request.subdomains.first
  return nil if locale.nil?
  I18n.available_locales.include?(locale.to_sym) ? locale.to_s : nil
end

#set_localeObject

set the locale based on the subdomain



10
11
12
# File 'lib/app/controllers/inline_forms_application_controller.rb', line 10

def set_locale
  I18n.locale = extract_locale_from_subdomain || I18n.default_locale
end