cant use Activerecord find method with associations.
        Posted  
        
            by fenec
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by fenec
        
        
        
        Published on 2010-05-04T20:59:50Z
        Indexed on 
            2010/05/04
            21:08 UTC
        
        
        Read the original article
        Hit count: 370
        
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.
© Stack Overflow or respective owner