From 77c76b7a3193cb7db67a784117241538e9029150 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Fri, 25 Oct 2019 23:47:38 +0200 Subject: [PATCH] Add matches method to tournament The method collects all matches from all stages --- app/models/tournament.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/tournament.rb b/app/models/tournament.rb index ec71609..6a52b62 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -16,6 +16,10 @@ class Tournament < ApplicationRecord after_initialize :generate_code + def matches + stages.map(&:matches).flatten + end + private def generate_code