app/controllers/application_controller.rb
# frozen_string_literal: true # ApplicationController is the only controller# which inherits from ActionController::Base.# All other controllers in turn inherit from ApplicationControllerclass ApplicationController < ActionController::Base before_action :configure_permitted_parameters, if: :devise_controller? before_action :set_locale # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception def after_sign_out_path_for(_resource_or_scope) request.referer end protected def configure_permitted_parameters devise_parameter_sanitizer.permit(:sign_up, keys: %i[first_name last_name]) devise_parameter_sanitizer.permit(:account_update, keys: %i[first_name last_name]) end def set_locale I18n.locale = extract_locale || I18n.default_locale end def extract_locale parsed_locale = params[:locale] I18n.available_locales.map(&:to_s).include?(parsed_locale) ? parsed_locale : nil end # persist current locale through requests def default_url_options(options = {}) { locale: I18n.locale }.merge options endend