Sha256: 5d6105e3e179755e7165704819f0b26a3c41dd2f03640a2e0b97c332892549c4

Contents?: true

Size: 534 Bytes

Versions: 15

Compression:

Stored size: 534 Bytes

Contents

class BusList < ApplicationRecord
  validates_presence_of :name, :capacity
  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

15 entries across 15 versions & 1 rubygems

Version Path
hackathon_manager-0.11.2 app/models/bus_list.rb
hackathon_manager-0.11.1 app/models/bus_list.rb
hackathon_manager-0.11.0 app/models/bus_list.rb
hackathon_manager-0.10.3 app/models/bus_list.rb
hackathon_manager-0.10.2 app/models/bus_list.rb
hackathon_manager-0.10.1 app/models/bus_list.rb
hackathon_manager-0.10.0 app/models/bus_list.rb
hackathon_manager-0.9.2 app/models/bus_list.rb
hackathon_manager-0.9.1 app/models/bus_list.rb
hackathon_manager-0.9.0 app/models/bus_list.rb
hackathon_manager-0.8.2 app/models/bus_list.rb
hackathon_manager-0.8.1 app/models/bus_list.rb
hackathon_manager-0.8.0 app/models/bus_list.rb
hackathon_manager-0.7.1 app/models/bus_list.rb
hackathon_manager-0.7.0 app/models/bus_list.rb