Files
old-zsterminator/app/controllers/application_controller.rb
2025-04-24 21:20:28 +02:00

35 lines
879 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
# This should be handled by your authentication system
# But for now, we'll use a placeholder
company_id = session[:company_id]
unless company_id && Company.exists?(company_id)
# If no company in session or it doesn't exist, use the first company
company_id = Company.first&.id
session[:company_id] = company_id
end
@company = Company.find(company_id) if company_id
end
def current_company
@company
end
helper_method :current_company
end