If you want to do it in one call instead of two, you can use the update_all
method like this:
Player.where(:grepo_id => a[:grepo_id]).update_all(a)
This will result in the following SQL:
UPDATE players SET ... = ..., ... = ... WHERE players.grepo_id = ...
Also works if the grepo_id
doesn't exist: nothing will get updated. Note however that this just runs the SQL; any validations or callbacks on your model are ignored.