here are my models:
#game
class Game < ActiveRecord::Base
#relationships with the teams for a given game
belongs_to :team_1,:class_name=>"Team",:foreign_key=>"team_1_id"
belongs_to :team_2,:class_name=>"Team",:foreign_key=>"team_2_id"
def self.find_games(name)
items = Game.find(:all,:include=>[:team_1,:team_2] , :conditions => ["team_1.name = ?", name] )
end
end
#teams
class Team < ActiveRecord::Base
#relationships with games
has_many :games, :foreign_key =>'team_1'
has_many :games, :foreign_key =>'team_2'
end
When i execute Game.find_games("real") i get : ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: team_1.name
How can i fix the problem i thought that using :include would fix the problem.