Sports Match Model

Hi,

I'm looking to model a set of fixtures for a sports league.

I've got a team model {id*, name} And a match model {id*, date, homeTeam, homeScore, awayTeam, awayScore}

I'd like the team.id to appear in the match.homeTeam and match.awayTeam (ie. twice in the same record) as one team plays another in a given match. How would I go about modelling this in Rails?

I understand that in MySQL you select team.id twice giving each a different alias.

Thanks a lot,

Pootsy

class Match < ActiveRecord::Base    belongs_to :home_team, :class_name => 'Team', :foreign_key => :home_team_id    belongs_to :away_team, :class_name => 'Team', :foreign_key => :away_team_id end

Note that the :foreign_key is required in Rails 1.2 (the default being the class name with "_id"), but will be redundant in Rails 2.0 as the default will be built from the association name.

-Rob

Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com