I’ve got a Match and a Team model in my Rails application.
A match has two teams team1 and team2. How do I set up my Team model to make it have an attribute matches containing matches when the team is team1 and when the team is team2 ?
Note: I’d like to be able to use it like any Rails association like matches.delete_all for instance.
There are two associations. I used home_team and away_team instead of team1 and team2:
To delete all matches for a team, you need to delete both associated matches. In team.rb: