mardi 27 octobre 2015

how to covert array object to hash in rails

i have a hash with array object :

{
  false=>[#<Campaign id: 1, name: "campaign 1", active: false>, #<Campaign id: 3, name: "campaign 3", active: false>, #<Campaign id: 4, name: "campaign 4", active: false>], 
  true=>[#<Campaign id: 2, name: "campaign 2", active: true>]
} 

how to convert above hash to hash

{
  false=>[{id:1, name:"campaign 1"}, {id:3, name: "capaign 3"}, ....],
  true =>[{id:2, name:"campaign 2"}]
}

Aucun commentaire:

Enregistrer un commentaire