Search the web
Sign In
New User? Sign Up
RubyOnRails · Ruby on Rails
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
table has two references to same table   Message List  
Reply | Forward Message #90 of 107 |
hi there,

i got to tables "teams" and "matches".

create_table :teams do |t|
t.string :name
t.timestamps
end

create_table :matches do |t|
t.datetime :kickoff
t.timestamps
end

i have to reference two teams (home & away) in the matches table. but
i dont know how to do it.

when i do something like this:

t.column 'home_team_id', :integer
t.column 'away_team_id', :integer

then i loose the association to the teams-table.

anyone with a tip for me? any help is highly appreciated.




Wed Jan 30, 2008 11:21 am

tmangner
Offline Offline
Send Email Send Email

Forward
Message #90 of 107 |
Expand Messages Author Sort by Date

hi there, i got to tables "teams" and "matches". create_table :teams do |t| t.string :name t.timestamps end create_table :matches do |t| t.datetime :kickoff ...
Torsten Mangner
tmangner
Offline Send Email
Jan 30, 2008
1:17 pm

Hi Torsten, I am not sure I entire understand your situation, but if I were you this is how I might set it up: First, I would have a table teams, a table...
mpfilbin
Offline Send Email
Jan 30, 2008
5:51 pm

... thx, mpfilbin. i knew how to use habtm, but thats not what i wanted. i dont want to have 1 or 3 or 4 teams on a match, but exactly two: one home, one away ...
Torsten Mangner
tmangner
Offline Send Email
Jan 30, 2008
6:20 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help