match.rb 361 Bytes
class Match < ApplicationRecord

  belongs_to :pool, inverse_of: :matches
  has_many :bets, dependent: :destroy, inverse_of: :match
  validates :home, :away, :date, :pool, presence: true
  enum result: [:home, :tie, :away]

  scope :active, -> { joins(:pool).where(pools: { active: true}) }
  scope :upcoming, -> { active.where('date > ?', Time.zone.now) }
end