Кажется, я не могу добавить элементы в хэш.Как добавить элементы хэша в другой хеш?
У меня есть следующий метод, который содержит хэш, и цель состоит в том, чтобы передать новый хэш, сделанный из оригинала. Я проверил, что ключ является строкой, а два других элемента - поплавками. b_name, lat и lng все печатаются в журналах, когда я запрашиваю.
def construct_paint_hash(list)
full_list = Hash.new
num = 100
list.each do |thing|
puts num
b_name = thing["name"]
puts b_name
lng = thing["longitude"]
lat = thing["latitude"]
full_list["#{b_name}"]=[lng, lat]
# full_list[:dsfsd] = "dsfdsfds"
num +=100
end
return full_list
end
Здесь ошибка я получаю:
Completed 500 Internal Server Error in 377ms (ActiveRecord: 0.0ms)
TypeError (no implicit conversion of String into Integer):
app/controllers/welcome_controller.rb:42:in `[]'
app/controllers/welcome_controller.rb:42:in `block in construct_paint_hash'
app/controllers/welcome_controller.rb:39:in `each'
app/controllers/welcome_controller.rb:39:in `construct_paint_hash'
app/controllers/welcome_controller.rb:11:in `index'
Какого черта я здесь делаю неправильно?
Могу ли я увидеть код, который вызывает 'construct_paint_hash (список)'? –
'лат = get_lat()' ' LNG = get_lng()' ' thing_search = HTTParty.get (construct_location_search (лат, LNG)) [ "данные"]' ' thing_location_hash = construct_paint_hash (thing_search)' 'puts construct_paint_hash (thing_location_hash)' – notthehoff
Извините, что прокомментировал катастрофу – notthehoff