title: Populating ruby hash:- by hash of hashes with array values
body: <p>My DB response looks like this:</p>
  
  <pre><code>response = [
  {id: 1, name: Kassandra, group: Sparta, role: Mercenary}
  {id: 2, name: Alexios, group: Sparta, role: Mercenary}
  {id: 3, name: Herakles, group: Athens, role: Champion}
  ]
  </code></pre>
  
  <p>My method:</p>
  
  <pre><code>def get_group_details
    grouped_details = []
  
    response.each do |key|
    key['group'] = key
    grouped_details.push(key)
    end
  
  end
  </code></pre>
  
  <p>Which results in <strong>stack_level_too_deep</strong> error, on looking I believe it's leading to an infinite loop... 
  What I am trying to manipulate the response to send to UI:</p>
  
  <pre><code> response: [
     Mercenary: {
           [{id: 1, name: Kassandra, group: Sparta, role: Mercenary}, {id: 2, name: Alexios, group: Sparta, role: Mercenary}]
  }
    Champion: [{id: 3, name: Herakles, group: Athens, role: Champion}]
  ]
  </code></pre>
  
  <p>What am I missing?</p>