diff --git a/frameworks/Ruby/hanami/app/actions/updates/index.rb b/frameworks/Ruby/hanami/app/actions/updates/index.rb index 88c85a2ff60..3e68be733be 100644 --- a/frameworks/Ruby/hanami/app/actions/updates/index.rb +++ b/frameworks/Ruby/hanami/app/actions/updates/index.rb @@ -13,7 +13,7 @@ class Index < HelloWorld::Action def handle(request, response) worlds = ALL_IDS.sample(queries(request)).map do |id| - world_repo.update(id) + world_repo.update_random_number(id) end response.format = :json response.body = worlds.to_json diff --git a/frameworks/Ruby/hanami/app/repos/world_repo.rb b/frameworks/Ruby/hanami/app/repos/world_repo.rb index 40baa32c089..42a5c6f8a7c 100644 --- a/frameworks/Ruby/hanami/app/repos/world_repo.rb +++ b/frameworks/Ruby/hanami/app/repos/world_repo.rb @@ -7,13 +7,12 @@ def find(id) worlds.by_pk(id).one end - def update(id) - world = worlds.by_pk(id) - world_hash = world.one.to_h + def update_random_number(id) + world = find(id) + world_hash = world.to_h new_value = random_id new_value = random_id while new_value == world_hash[:randomnumber] - world_hash[:randomnumber] = new_value - world.changeset(:update, **world_hash).commit + worlds.where(id: id).update({ randomnumber: new_value }) world_hash end