search for: hometeam_id

Displaying 3 results from an estimated 3 matches for "hometeam_id".

Did you mean: home_team_id
2006 Jan 09
3
Include with two references of one model of the same table
...ot;matches" where I think should be two selects on two aliases of "matches". Heres some code below to better understand what I''m talking about. class Match < ActiveRecord::Base belongs_to :hometeam, :class_name => "TeamsSeason", :foreign_key => "hometeam_id" belongs_to :awayteam, :class_name => "TeamsSeason", :foreign_key => "awayteam_id" end class TeamsSeason < ActiveRecord::Base has_many :hometeam, :class_name => "Match", :foreign_key => "hometeam_id", :dependent => :destroy ha...
2007 Oct 16
8
Using multiple foreign keys in views
...:teams. There''s a home team and an away team. I created two foreign keys, so each game can have two teams associated 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 somethi...
2007 Oct 15
2
Association Help , 2 Teams playing a FootballGame
So I have the models class FootballGame < ActiveRecord::Base end and class Team < ActiveRecord::Base end I want to be able to do something like this @t1 = Team.create(:name=>"Michigan Wolverines football") @t1.save @t2 = Team.create(:name=>"Penn State Nittany Lions football") @t2.save @g = FootballGame.create(:hometeam => @t1, :awayteam => @t2) @g.save