Topic: Get win-loss for each team in Teams table using Games table?

Im creating an app using RoR to manage a basketball league. I have two tables: `Teams` & `Games`. The `Games` table takes two teams using foreign keys and contains the amount scored by each team like so:

home_team_id
away_team_id
home_team_score
away_team_score

Now, I would like to list all the teams, followed by their win-loss record. I cannot think of an easier way of doing this rather than a foreach loop that counts all the records in the games table that contains the team, and the team has more than the other team. And then again for losses. There has to be an easier way.

Any suggestions?