title: ruby (w/rails) group_by, then group_by again
body: <p>Is there a better way to do the following?</p>
  
  <pre><code>prices = Price...all.group_by(&amp;:foreign_key_id)
  @prices = Hash.new
  prices.each {|k, v| @prices[k] = Hash.new if !@prices[k]; @prices[k] = v.group_by {|g| g.created_at.to_time.to_i } }
  </code></pre>
  
  <p>I'd like to do something like</p>
  
  <pre><code>prices.each {|k,v| v = v.group_by(&amp;:created_at) }
  </code></pre>
  
  <p>But this doesn't seem to work because v is an array and group_by produces a hash. Perhaps there's a way to do this with inject?</p>