title: In Rails, what is the best way to compact a hash into a nested hash
body: <p>Say I have this:</p>
  
  <pre><code>[
    { :user_id =&gt; 1, :search_id =&gt; a},
    { :user_id =&gt; 1, :search_id =&gt; b},
    { :user_id =&gt; 2, :search_id =&gt; c},
    { :user_id =&gt; 2, :search_id =&gt; d}
  ]
  </code></pre>
  
  <p>and I want to end up with:</p>
  
  <pre><code>[
    { :user_id =&gt; 1, :search_id =&gt; [a,b]},
    { :user_id =&gt; 2, :search_id =&gt; [c,d]}
  ]
  </code></pre>
  
  <p>What is the best way to do that?</p>