| 
				
			 | 
			
			
				@@ -19,6 +19,8 @@ class Participant < ApplicationRecord 
			 | 
		
	
		
			
			| 
				19
			 | 
			
				19
			 | 
			
			
				   belongs_to :activity 
			 | 
		
	
		
			
			| 
				20
			 | 
			
				20
			 | 
			
			
				   belongs_to :subgroup, optional: true 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				21
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				22
			 | 
			
			
				+  after_validation :clear_subgroup, if: 'self.attending != true' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				23
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				24
			 | 
			
			
				   validates :person_id, 
			 | 
		
	
		
			
			| 
				23
			 | 
			
				25
			 | 
			
			
				     uniqueness: { 
			 | 
		
	
		
			
			| 
				24
			 | 
			
				26
			 | 
			
			
				       scope: :activity_id, 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -76,4 +78,9 @@ class Participant < ApplicationRecord 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				78
			 | 
			
			
				     ParticipantMailer.subgroup_notification(self.person, self.activity, self).deliver_later 
			 | 
		
	
		
			
			| 
				77
			 | 
			
				79
			 | 
			
			
				   end 
			 | 
		
	
		
			
			| 
				78
			 | 
			
				80
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				81
			 | 
			
			
				+  # Clear subgroup if person is set to 'not attending'. 
			 | 
		
	
		
			
			| 
				
			 | 
			
				82
			 | 
			
			
				+  def clear_subgroup 
			 | 
		
	
		
			
			| 
				
			 | 
			
				83
			 | 
			
			
				+    self.subgroup = nil 
			 | 
		
	
		
			
			| 
				
			 | 
			
				84
			 | 
			
			
				+  end 
			 | 
		
	
		
			
			| 
				
			 | 
			
				85
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				79
			 | 
			
				86
			 | 
			
			
				 end 
			 |