Column Names? Many-to-many on same table...

Hi folks,

I'm putting together an app to track scores for a kids sports league, and I can't figure out how to name the columns in my "games" table. I'll need a "home team ID" column and an "away team ID" column, but since they both reference the "teams" table, Rails conventions would give them both the name "team_id", which is obviously not going to work.

I've googled, and I've looked in the wiki, but I can't seem to find any documentation on how to handle a situation like this. How would you guys do it?

Also, is there a way for the many-to-many table to represent an object with its own properties rather than being merely a link between two other objects (e.g. a game has a date)?

Thanks!

class Game   belongs_to :home_team, :class => 'Team', :foreign_key => 'home_team_id'   belongs_to :away_team, :class => 'Team', :foreign_key => 'away_team_id'   ... end

class Team   has_many :games end

ringemup@gmail.com wrote:

Aha - that makes waaay too much sense! Thanks!

Thanks, I'll take a look.