Fix Stage.teams returning nil on error

This commit is contained in:
Thor77 2019-05-07 11:39:25 +02:00
parent 1690755c4f
commit 894608c19e
No known key found for this signature in database
GPG Key ID: 5051E71B46AA669A
1 changed files with 7 additions and 3 deletions

View File

@ -8,8 +8,12 @@ class Stage < ApplicationRecord
delegate :owner, to: :tournament
def teams
return matches.map(&:teams).flatten.uniq unless matches.size.zero?
groups.map(&:teams).flatten.uniq unless groups.size.zero?
if !matches.size.zero?
matches.map(&:teams).flatten.uniq
elsif !groups.size.zero?
groups.map(&:teams).flatten.uniq
else
[]
end
end
end