Ruby ですべてのレコードをロードしてカウントするのは避けた方がよいという意見には同意します。SQL クエリで実行すると、はるかに高速になります。
def team_stats(team_id)
# Wins are any game where the team played and scored higher than the other team
wins = Game.where('(home_team_id = ? AND home_team_score > away_team_score) OR (away_team_id = ? AND home_team_score < away_team_score)', team_id, team_id).count
# The opposite for losses
losses = Game.where('(home_team_id = ? AND home_team_score < away_team_score) OR (away_team_id = ? AND home_team_score > away_team_score)', team_id, team_id).count
# Ties are not accounted for
return {:wins => wins, :losses => losses}
end