I am new to rails. I’m trying to update all records in a
table where a join is required.
Table: players
id games_id pointsTable: games
idDesire SQL:
Update players
Set points = 1
From players, games
where games_id = games.id
Rails Code I tried:
Player.rb { model }
def self.update_points
results = Player.update_all(“points = 1”, “games_id = Game.id”)
end
I tried different combinations, don’t seem to recognize
Game.id — saying games don’t exist.
I have Game.rb generated by using scaffold command.
I am new to rails. I’m trying to update all records in a
table where a join is required.
Table: players
id games_id pointsTable: games
idDesire SQL:
Update players
Set points = 1
From players, games
where games_id = games.id
Rails Code I tried:
Player.rb { model }
def self.update_points
results = Player.update_all(“points = 1”, “games_id = Game.id”)
end
I tried different combinations, don’t seem to recognize
Game.id — saying games don’t exist.
I have Game.rb generated by using scaffold command.