In this situation, you'd use @team.id
for each, like @EricAndres said.
However, you'll also want some additional parenthesis in your where
clause to make it work right:
@team.games.where("(home_team_id = ? AND home_score > away_score) OR (away_team_id = ? AND away_score > home_score)", @team.id, @team.id)
Update
Since this is on the Game
model, how about a class method on that model called won_by
which takes a team
:
class Game < ActiveRecord::Base
def self.won_by(team)
where("(home_team_id = ? AND home_score > away_score) OR (away_team_id = ? AND away_score > home_score)", team.id, team.id)
end
end