mirror of
				https://github.com/fspc/bike-database.git
				synced 2025-10-31 16:45:34 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			623 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			623 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| class Client < ActiveRecord::Base
 | |
|   validates :application_date, presence: true
 | |
|   has_one :bike
 | |
|   belongs_to :agency
 | |
| 
 | |
|   def self.waiting_list
 | |
|     clients = Client.all
 | |
|     non_voided_clients = clients.select{|client| !client.application_voided}
 | |
|     waiting_list = non_voided_clients.select{|client| !client.completion_date}
 | |
|     waiting_list.sort_by!{|client| client.application_date}
 | |
|   end
 | |
| 
 | |
|   def name
 | |
|     self.first_name + ' ' + self.last_name
 | |
|   end
 | |
| 
 | |
|   def self.closed_applications
 | |
|     Client.all.select{|client| client.application_voided || client.completion_date}
 | |
|   end
 | |
| 
 | |
|   def bike
 | |
|     Bike.find(self.bike_id)
 | |
|   end
 | |
| 
 | |
| end
 |