I’m currently building a mini stat page and tracking some users stats
that I would like to combine into a large table for an overview. I
currently have the following…
@new_users = [{“May Sat 03”=>5}, {“May Fri 02”=>1}, {“May Thu
01”=>4}]
@new_entries = [{“May Sat 03”=>2}, {“May Fri 02”=>3}, {“May Thu
01”=>4}]
@new_winners = [{“May Sat 03”=>3}, {“May Fri 02”=>4}, {“May Thu
01”=>4}]
I would like to generate one master array that I can iterate using a
table. My thinking is I would want to have one master array that looks
like this.
@master_list = [ {“May Sat 03”=> [5,2,3]}, {“May Sat 02”=> [1,3,4]},
{“May Sat 01”=> [4,4,4]} ]
or should it look might look like this
@master_list = [{“May Sat 03”=>
[“new_users”=>“5”,“new_entries”=>“2”,“new_winners”=>“3”]},
{“May Sat 03”=>
[“new_users”=>“5”,“new_entries”=>“2”,“new_winners”=>“3”]},
{“May Sat 03”=>
[“new_users”=>“5”,“new_entries”=>“2”,“new_winners”=>“3”]}
]
I would think this first option seems the easiest to produce?
Is there a way in Ruby or in Rails to tell each array to find the
exact same index/key (which are the dates) and merge it’s values? I
have been playing around with Array.find_all and Array.inject but
nothing seems to be clicking on how I would generate the final
@master_list