diff --git a/app/models/stage.rb b/app/models/stage.rb index b43d80c..5e1d9d0 100644 --- a/app/models/stage.rb +++ b/app/models/stage.rb @@ -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