Forum: Ruby on Rails Doozy of a pagination problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2119f016588ba13373484491bd2dd6d1?d=identicon&s=25 Joe Peck (fatcatt316)
on 2008-12-15 16:19
Hey,

This is sort of complicated, and I'm trying to keep it as simple as I
can.

I'm using will_paginate to display only 25 snapshots on each page.  My
question is how can I return only the most recent snapshot per link
(just one per link)?

@snapshots = Snapshot.paginate :order => 'snapshots.weighted_score
desc', :conditions => ["snapshots.scenario_id = ? and (links.status = 1
or links.status = 2 or links.status = 4)", @scenario.id], :include =>
[:page, :link, {:snapshot_attributes => :attribute}], :page =>
params[:page], :per_page => 25

Let me know if any other information is needed, and thanks for any
advice.
This topic is locked and can not be replied to.