Sha256: 632d3826f23668606023c0523944495b38963a740990a688c2eac3b4c755f634

Contents?: true

Size: 523 Bytes

Versions: 2

Compression:

Stored size: 523 Bytes

Contents

class BusList < ApplicationRecord
  validates_presence_of :name, :capacity
  validates_uniqueness_of :name

  has_many :questionnaires

  strip_attributes

  def full?
    passengers.count >= capacity
  end

  def passengers
    questionnaires.where("acc_status = 'rsvp_confirmed'").order("last_name ASC")
  end

  def schools
    passengers.joins(:school).map(&:school).uniq
  end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hackathon_manager-0.12.1 app/models/bus_list.rb
hackathon_manager-0.12.0 app/models/bus_list.rb