Forum: Ruby on Rails paginate a collection

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.
John C. (Guest)
on 2006-03-18 16:08
hi i want to paginate a collection found by complex sql query
how can i do
thanks
Wilson B. (Guest)
on 2006-03-18 19:08
(Received via mailing list)
On 3/18/06, john carter <removed_email_address@domain.invalid> wrote:
> hi i want to paginate a collection found by complex sql query
> how can i do
> thanks
>
> --

Check out this page:
http://www.bigbold.com/snippets/posts/show/389
John C. (Guest)
on 2006-03-19 10:13
thank you for your answer
i've tested this code but only the first page is displayed
i cant display the others pages
Wilson B. (Guest)
on 2006-03-19 19:05
(Received via mailing list)
On 3/19/06, john carter <removed_email_address@domain.invalid> wrote:
> thank you for your answer
> i've tested this code but only the first page is displayed
> i cant display the others pages
>
>

Check out the comments below the code snippet, at the original URL.
You need to include the :page => some_variable option manually when
using that code.
One way would be to say:
page = params[:page] || 1
paginate_collection(:page => page) { big complex query here }

One thing to be aware of is that paginating in memory like this can be
much slower than having your database do it. You should only use this
method when paginating something that can't be made compatible with
'LIMIT' and 'OFFSET'.
This topic is locked and can not be replied to.