I have a fixtures and a teams database to show football fixtures. I can currently view all fixtures(index & show..) and all teams(index only).
create_table "fixtures", :force => true do |t|
t.integer "home_id"
t.integer "away_id"
t.date "date"
...
create_table "teams", :force => true do |t|
t.string "name"
...
My Fixture & Team models are below;
class Fixture < ActiveRecord::Base
belongs_to :home, :class_name => 'Team'
belongs_to :away, :class_name => 'Team'
...
class Team < ActiveRecord::Base
has_many :fixtures
...
I get the following error when trying to display a teams fixtures on 'teams#show' page
Processing by TeamsController#show as HTML
Parameters: {"id"=>"3"}
Team Load (0.4ms) SELECT "teams".* FROM "teams" WHERE ("teams"."id" = 3) LIMIT 1
Fixture Load (0.3ms) SELECT "fixtures".* FROM "fixtures"
Fixture Load (0.3ms) SELECT "fixtures".* FROM "fixtures" WHERE ("fixtures".team_id = 3)
SQLite3::SQLException: no such column: fixtures.team_id: SELECT "fixtures".* FROM "fixtures" WHERE ("fixtures".team_id = 3)
I understand the error is saying it's looking for team_id in the fixtures but that doesn't exist as I have a home_id and away_id as each fixture always contains two teams, so how do I build a find to display an individual teams fixtures?