Sha256: 6186edd260a87b121fe725c6cf566d6684068f074eb3610c3d68bc803155dd91

Contents?: true

Size: 523 Bytes

Versions: 30

Compression:

Stored size: 523 Bytes

Contents

class BusList < ApplicationRecord
  validates_presence_of :name
  validates_uniqueness_of :name

  has_many :schools

  strip_attributes

  def full?
    passengers.count >= capacity
  end

  def passengers
    Questionnaire.joins(:school).where("schools.bus_list_id = '#{id}' AND acc_status = 'rsvp_confirmed' AND riding_bus = true").order("schools.name ASC, last_name ASC")
  end

  def checked_in_passengers
    passengers.select(&:checked_in?)
  end

  def captains
    passengers.where(is_bus_captain: true)
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
hackathon_manager-0.6.6 app/models/bus_list.rb
hackathon_manager-0.6.5 app/models/bus_list.rb
hackathon_manager-0.6.4 app/models/bus_list.rb
hackathon_manager-0.6.3 app/models/bus_list.rb
hackathon_manager-0.6.2 app/models/bus_list.rb
hackathon_manager-0.6.1 app/models/bus_list.rb
hackathon_manager-0.6.0 app/models/bus_list.rb
hackathon_manager-0.5.11 app/models/bus_list.rb
hackathon_manager-0.5.10 app/models/bus_list.rb
hackathon_manager-0.5.9 app/models/bus_list.rb
hackathon_manager-0.5.8 app/models/bus_list.rb
hackathon_manager-0.5.7 app/models/bus_list.rb
hackathon_manager-0.5.6 app/models/bus_list.rb
hackathon_manager-0.5.5 app/models/bus_list.rb
hackathon_manager-0.5.4 app/models/bus_list.rb
hackathon_manager-0.5.3 app/models/bus_list.rb
hackathon_manager-0.5.2 app/models/bus_list.rb
hackathon_manager-0.5.1 app/models/bus_list.rb
hackathon_manager-0.5.0 app/models/bus_list.rb
hackathon_manager-0.4.4 app/models/bus_list.rb