app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
before_action :set_locale
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:name, :email, :password, :password_confirmation, :remember_me) }
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:email, :password, :remember_me) }
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:name, :email, :password, :password_confirmation, :current_password) }
end
def default_url_options(options = {})
{ locale: I18n.locale }.merge options
end
def set_locale
I18n.locale = params[:locale] || get_locale_from_domain || I18n.default_locale
end
def get_locale_from_domain
locale = BP_CONFIG['localized_domains'][request.host] || ""
I18n.available_locales.include?(locale.to_sym) ? locale : nil
end
end