Delegate Account#user_locale method and allow nil (#2927)
This commit is contained in:
		
				
					committed by
					
						
						Eugen Rochko
					
				
			
			
				
	
			
			
			
						parent
						
							cd830a2fab
						
					
				
				
					commit
					7a7d12d27f
				
			@@ -35,6 +35,6 @@ class LanguageDetector
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def default_locale
 | 
			
		||||
    account&.user&.locale || I18n.default_locale
 | 
			
		||||
    account&.user_locale || I18n.default_locale
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -71,7 +71,7 @@ class NotificationMailer < ApplicationMailer
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def locale_for_account(account)
 | 
			
		||||
    I18n.with_locale(account.user.locale || I18n.default_locale) do
 | 
			
		||||
    I18n.with_locale(account.user_locale || I18n.default_locale) do
 | 
			
		||||
      yield
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -111,6 +111,7 @@ class Account < ApplicationRecord
 | 
			
		||||
           :current_sign_in_ip,
 | 
			
		||||
           :current_sign_in_at,
 | 
			
		||||
           :confirmed?,
 | 
			
		||||
           :locale,
 | 
			
		||||
           to: :user,
 | 
			
		||||
           prefix: true,
 | 
			
		||||
           allow_nil: true
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user