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.
5bb270a2d6a979e5e77b1a50edefdaf5?d=identicon&s=25 John Carter (amin1426)
on 2006-03-18 15:08
hi i want to paginate a collection found by complex sql query
how can i do
thanks
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2006-03-18 18:08
(Received via mailing list)
On 3/18/06, john carter <amin1425@yahoo.fr> 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
5bb270a2d6a979e5e77b1a50edefdaf5?d=identicon&s=25 John Carter (amin1426)
on 2006-03-19 09:13
thank you for your answer
i've tested this code but only the first page is displayed
i cant display the others pages
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2006-03-19 18:05
(Received via mailing list)
On 3/19/06, john carter <amin1425@yahoo.fr> 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.