Skip to content

Commit 1ed28bf

Browse files
authored
[ruby/rails] Use batch update for /update (#9017)
* [ruby/rails] Update trilogy to 2.8.1 and use ssl for connection This fixes connection errors: /usr/local/bundle/gems/activerecord-7.1.3.1/lib/active_record/connection_adapters/trilogy_adapter.rb:61:in `rescue in new_client': trilogy_auth_recv: caching_sha2_password requires either TCP with TLS or a unix socket: TRILOGY_UNSUPPORTED (ActiveRecord::ConnectionNotEstablished) * [ruby/rails] Use batch update for /update Use a single query for updating the world records.
1 parent 09f2ac7 commit 1ed28bf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

frameworks/Ruby/rails/app/controllers/hello_world_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ def update
3737
world = World.find(id)
3838
new_value = random_id
3939
new_value = random_id until new_value != world.randomNumber
40-
world.update_columns(randomNumber: new_value)
41-
world
40+
{ id: id, randomNumber: new_value }
4241
end
42+
World.upsert_all(worlds.sort_by!{_1[:id]})
4343

4444
render json: worlds
4545
end

0 commit comments

Comments
 (0)