Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id | Name
- 1 | some-name#1
- 2 | some-name#2
- 3 | some-name#3
- id | team_id1 | team_id2 | result1 | result2
- 1 | 2 | 3 | -1 | -1
- has_many :matches
- belongs_to :team_one, :foreign_key => "team_id1", :class_name => "Team"
- belongs_to :team_two, :foreign_key => "team_id2", :class_name => "Team"
- match = match.find(1)
- match.team_one.name ### gives -> some-name#2
- match.team_two.name ### gives -> some-name#3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement