У меня есть массив хэшей, это выглядит как
arr = [
{"partner_name"=>"Bell", "publisher_name"=>"News - Calgary", "mn"=>"", "mid"=>415},
{"partner_name"=>"Bell", "publisher_name"=>"News - Vancouver Island", "mn"=>"Module 2.0 ", "mid"=>4528},
{"partner_name"=>"Bell", "publisher_name"=>"News - Atlantic", "mn"=>"Module 2.0 ", "mid"=>4531},
{"partner_name"=>"Bell", "publisher_name"=>"News - Kitchener", "mn"=>"Module 2.0 ", "mid"=>4535},
{"partner_name"=>"Bell", "publisher_name"=>"News - London", "mn"=>"Module 2.0 ", "mid"=>4536},
{"partner_name"=>"Bell", "publisher_name"=>"News - Ottawa", "mn"=>"Module 2.0 ", "mid"=>4539},
{"partner_name"=>"Bell", "publisher_name"=>"News - Regina", "mn"=>"Module 2.0 ", "mid"=>4540},
{"partner_name"=>"Bell", "publisher_name"=>"News - Saskatoon", "mn"=>"Module 2.0 ", "mid"=>4541},
{"partner_name"=>"Bell", "publisher_name"=>"News - Toronto", "mn"=>"Module 2.0 ", "mid"=>4542},
{"partner_name"=>"Bell", "publisher_name"=>"News - Windsor", "mn"=>"Module 2.0 ", "mid"=>4544},
{"partner_name"=>"Bell", "publisher_name"=>"CP24", "mn"=>"Module 2.0 Platform", "mid"=>5413},
]
Я пытался сделать arr.group_by{|el|el['partner_name']}
я хочу добиться этого результата
{
partner:'Bell',
publishers: [
{name:'News - Vancouver Island'},
{name:'News - Vancouver Island'},
# ... and others
],
modules:[
{mn: val, mid: id_val},
# ...
],
}