Displaying 1 result from an estimated 1 matches for "visitingteam_id".
2007 Oct 16
8
Using multiple foreign keys in views
...ciated with it. Here''s the Team model:
class Team < ActiveRecord::Base
belongs_to :game,
:class_name => ''Game'', :foreign_key => ''hometeam_id''
belongs_to :game,
:class_name => ''Game'', :foreign_key => ''visitingteam_id''
end
Now, assuming that works correctly, how do I use those associations in
my view. Let''s say I want to show the names of the teams in a game.
Doing something like this doesn''t work: <%= game.team.name %> because it
doesn''t specify which team I''m...