Sure there should be something about it because there's 2 teams per
games.
But Teams belongs to League and Games belongs to 2 Teams. But since
there a direct link between Team and League I didn't expect the Games to
affect the Team list (I would have expected it the other way around with
2 times each games).
See below my models:
class League < ActiveRecord::Base
has_many :teams
has_many :games, :through => :teams
end
class Team < ActiveRecord::Base
belongs_to :club
belongs_to :league
has_many :games, :foreign_key => 'team_a_id'
has_many :games, :foreign_key => 'team_b_id'
end
class Game < ActiveRecord::Base
belongs_to :team_a, :class_name => 'Team', :foreign_key=>'team_a_id'
belongs_to :team_b, :class_name => 'Team', :foreign_key=>'team_b_id'
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---