Here is my code:
records_hash = records[:id].inject({}) { |result,h|
if result.has_key?(h)
result[h] += 1
else
result[h] = 1
end
result
}
@test2 = records_hash.each{|key,value| puts "#{key} is #{value}"}
My output should look like this:
bozo is 3
bubba is 4
bonker is 5
But it renders on the page (<%= @test2 %>
) as this:
bozo3bubba4bonker5
I've tried .each_key & .each-value with similar blocks and they all return the same string above. I run the same code in IRB and it works as expected.
What am I doing wrong?