title: Ruby ActiveRecord Maximum
body: <p>I am working with a Rails app that I need to return the maximum value for a particular row but also need to return the rest of the row contents.</p>
  
  <p>Code:<br/></p>
  
  <pre><code>medias = Media.maximum(:id, :conditions =&gt; ['medias.image = true AND medias.subscriber_id  = 37'], :group =&gt; ['subscriber_id'])
  </code></pre>
  
  <p>This is only returning the id and subscriber_id, I need to return all of the rows not just those two.</p>
  
  <p>Example: In my medias table a subscriber can upload multiple photos. I am trying to group by the subscriber id and get the last entry for all subscribers. So basically I need a find all by maximum.</p>