Only validate display name when updated
Otherwise we needlessly fetch the validated one from LDAP every time a model is saved.
This commit is contained in:
		
							parent
							
								
									f74227fedb
								
							
						
					
					
						commit
						445cdfa024
					
				@ -33,7 +33,8 @@ class User < ApplicationRecord
 | 
				
			|||||||
  validates_uniqueness_of :email
 | 
					  validates_uniqueness_of :email
 | 
				
			||||||
  validates :email, email: true
 | 
					  validates :email, email: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  validates_length_of :display_name, minimum: 3, maximum: 35, allow_blank: true
 | 
					  validates_length_of :display_name, minimum: 3, maximum: 35, allow_blank: true,
 | 
				
			||||||
 | 
					                                     if: -> { defined?(@display_name) }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  scope :confirmed, -> { where.not(confirmed_at: nil) }
 | 
					  scope :confirmed, -> { where.not(confirmed_at: nil) }
 | 
				
			||||||
  scope :pending,   -> { where(confirmed_at: nil) }
 | 
					  scope :pending,   -> { where(confirmed_at: nil) }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user