I am trying to implement a dynamic JSON object in a Highcharts function and I am wondering is there a clever ruby way to do this.
Basically I have Users in my rails app, each with a country of origin in the ISO-a2 format. I need to get the numbers of members for each country into this format....(value will be the dynamic variable)
var data = [{"code":"AF","value":"<%= ruby code %>"},
{"code":"AX",.......and so on
I could start with
country_array = Array.new
User.all.map{|u| country_array << u.country}
But my attempts have resulted in horribly long messes. A suggestion if there is a smart way to do this would be great.