22 lines
535 B
Ruby
22 lines
535 B
Ruby
class ApplicationController < ActionController::Base
|
|
before_action :set_locale
|
|
|
|
private
|
|
|
|
def set_locale
|
|
I18n.locale = params[:locale] || session[:locale] || I18n.default_locale
|
|
session[:locale] = I18n.locale
|
|
end
|
|
|
|
# Optional: Make locale persist across requests via URL helpers
|
|
def default_url_options
|
|
{ locale: I18n.locale }
|
|
end
|
|
|
|
def set_company
|
|
company_id = session.fetch(:company_id, Company.first&.id)
|
|
session[:company_id] = company_id
|
|
@company = Company.find(session[:company_id])
|
|
end
|
|
end
|