From 046b48370ecd7cef217211b313dd5f2adbd47b2a Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Wed, 9 Jan 2019 08:27:52 -0500 Subject: [PATCH] tournament.total_rounds should return 0 if there are none --- app/models/tournament.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 97a3590..6eb5fa7 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -46,7 +46,11 @@ class Tournament < ActiveRecord::Base end def total_rounds - self.matches.sort_by{|m| m.round}.last.round + if self.matches.count > 0 + self.matches.sort_by{|m| m.round}.last.round + else + 0 + end end def assign_mats(mats_to_assign)