title: Rails: three most recent comments with unique users
body: <p>what would I put in the named scope :by_unique_users so that I can do Comment.recent.by_unique_users.limit(3), and only get one comment per user?</p>
  
  <pre><code>class User
    has_many :comments
  end
  
  class Comment
    belongs_to :user
    named_scope :recent, :order =&gt; 'comments.created_at DESC'
    named_scope :limit, lambda { |limit| {:limit =&gt; limit}}
    named_scope :by_unique_users
  end
  </code></pre>
  
  <p>on sqlite named_scope :by_unique_user, :group => "user_id" works,</p>
  
  <p>but makes it freak out on postgres, which is deployed on production
  PGError: ERROR:  column "comments.id" must appear in the GROUP BY clause or be used in an aggregate function</p>