I have a Teams model and a Fixtures model. The Fixtures model has an away team and a home team.I followed the example in this answer and have most things working.
class Fixture < ActiveRecord::Base
belongs_to :home, class_name: 'Team'
belongs_to :away, class_name: 'Team'
end
class Team < ActiveRecord::Base
has_many :home_games, :class_name => 'Fixture', :foreign_key => 'home_id'
has_many :away_games, :class_name => 'Fixture', :foreign_key => 'away_id'
end
I want to be able to call @team.fixtures to get a list of all of the teams fixtures, currently @team.home_games gives me the home fixtures and @team.away_games gives me the aways.
How can I write a has_many :games
similar to has_many :home_games
, and is that the best way to do it?