title: select vs distinct vs uniq?
body: <p>I am confused by Ruby's ActiveRecord uniq method. I am using it to try to get back an array of complete objects, not just a particular field. </p>
  
  <p>In my Padrino app script, which saves newspaper names and scores as Score objects, the uniq method by attribute on an ActiveRecord Relation is not working, and neither is distinct, with or without SQL syntax. Can anyone explain what is going on? </p>
  
  <pre><code>class Score &lt; ActiveRecord::Base
  
      def self.from_today
          self.where('created_at &gt; ?', Date.today)
      end
  end
  
  
  scores = Score.from_today
  scores.class      
  =&gt; Score::ActiveRecord_Relation 
  
  scores.first
  =&gt; #&lt;Score id: 123, score: -2.55, source: "Mail", created_at: "2016-08-11 04:29:24", updated_at: "2016-08-11 04:29:24"&gt;
  
  scores.map(&amp;:source) 
  =&gt; ["Mail", "Guardian", "Telegraph", "Independent", "Express", "Mail"]
  
  scores.uniq(:source).count 
  =&gt; 6
  
  scores.distinct(:source).count
  =&gt; 6
  
  scores.select('distinct (SOURCE)').count
  =&gt; 5    #AHA, it works!
  
  scores.select(:source).distinct
  =&gt; #&lt;ActiveRecord::Relation [#&lt;Score id: nil, source: "Telegraph"&gt;, #&lt;Score id: nil, source: "Mail"&gt;, #&lt;Score id: nil, source: "Independent"&gt;, #&lt;Score id: nil, source: "Express"&gt;, #&lt;Score id: nil, source: "Guardian"&gt;]&gt;
  
          #oops, no it doesn't
  </code></pre>