title: Cleanest way to create a Hash from an Array
body: <p>I seem to run into this very often.  I need to build a Hash from an array using an attribute of each object in the array as the key.</p>
  
  <p>Lets say I need a hash of example uses ActiveRecord objecs keyed by their ids
  Common way:</p>
  
  <pre><code>ary = [collection of ActiveRecord objects]
  hash = ary.inject({}) {|hash, obj| hash[obj.id] = obj }
  </code></pre>
  
  <p>Another Way:</p>
  
  <pre><code>ary = [collection of ActiveRecord objects]
  hash = Hash[*(ary.map {|obj| [obj.id, obj]}).flatten]
  </code></pre>
  
  <p>Dream Way:
  I could and might create this myself, but is there anything in Ruby or Rails that will this?</p>
  
  <pre><code>ary = [collection of ActiveRecord objects]
  hash = ary.to_hash &amp;:id
  #or at least
  hash = ary.to_hash {|obj| obj.id}
  </code></pre>