Displaying 2 results from an estimated 2 matches for "awayteam_id".
Did you mean:
away_team_id
2006 Jan 09
3
Include with two references of one model of the same table
...elow 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
has_many :awayteam, :class_name => "Match", :foreign_key =>
"awayteam_id", :dependent...
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