Add method to get all teams within a stage

This commit is contained in:
Daniel Schädler 2019-04-24 12:00:17 +02:00
parent 4664a67914
commit 1fdc292aaa
1 changed files with 4 additions and 0 deletions

View File

@ -4,4 +4,8 @@ class Stage < ApplicationRecord
belongs_to :tournament
has_many :matches, dependent: :destroy
has_many :groups, dependent: :destroy
def teams
groups.map{|g| g.matches.map{ |m| m.match_scores.map{ |ms| ms.team}}}.flatten.uniq
end
end