Paginate a collection

hi i want to paginate a collection found by complex sql query
how can i do
thanks

On 3/18/06, john carter [email protected] wrote:

hi i want to paginate a collection found by complex sql query
how can i do
thanks

Check out this page:

thank you for your answer
i’ve tested this code but only the first page is displayed
i cant display the others pages

On 3/19/06, john carter [email protected] 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’.