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)