I was using ActiveRecord to create a Hash with key => value.
@users = Hash.send :[], *ActiveRecord::Base.connection.execute('SELECT `id`, `name` FROM `users`').map {|x| x}.flatten
@users[1]
# => "User 1"
Since Hash [* Array] is used, stack overflow will occur if the number of records fetched by execute exceeds a certain level.
There is a problem with both how to use ActiveRecord and how to make Hash.
@users = User. User.pluck(:id, :name).to_h
@users[1]
# => "User 1"
Get the required column with .pluck
and hash it with .to_h