I am working on a site that includes soccer match scheduling. I have
the following basic mysql schema:
TABLE teams (
id
name
)
TABLE fixtures (
id
home_team_id
away_team_id
)
In the past, with mysql/php, I would have done something like this:
SELECT [...] FROM fixtures, teams AS t1, teams AS t2 WHERE
home_team_id=t1.id AND away_team_id=t2.id;
I am stumped as to how to do this with RoR using the ActiveRecord
belongs_to and has_many associations. I tried something like this to no
avail:
class Fixture < ActiveRecord::Base
belongs_to :team,
:foreign_key => "home_team_id"
belongs_to :team,
:foreign_key => "away_team_id"
end
with reciprocal references in the Team.rb model, but it didn''t seem to
work.
Any thoughts would be greatly appreciated.
--
Posted via http://www.ruby-forum.com/.