Ruby on Rails
HowtoUpdateAllWithMultipleTables

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 points

Table: games

id

Desire 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.

Comments from John Feltz
The key thing you’re doing wrong:
You need to have game_id, not games_id, in your players table.
It takes a little while to get used to what gets pluralized and what gets capitalized. Hang in there.