title: Get distinct elements from a Rails ActiveRecord query
body: <p>I've got a query in Rails like this:</p>
  
  <pre><code>@addresses=People.select("first_name, state").where("first_name = 'Bob'")
  </code></pre>
  
  <p>Is there a way I can iterate over addresses and pull out the distinct states, so that I know in which states someone named bob lives?</p>
  
  <p>I'm trying to avoid:</p>
  
  <pre><code>@states = []
  @address.each.do |add|
    if !@states.contains?(add.state)
      @states.push add
  </code></pre>
  
  <p>That just seems like bad form.</p>