#31 ✓invalid
Wayne Seguin

will_paginate doubles the number of pages that are actually there.

Reported by Wayne Seguin | June 14th, 2007 @ 03:43 AM

I am trying to use will_paginate and am running into an issue

whereby the will_paginate helper displays double the number of pages that there physically are. I think it has to do with the fact that we're using quite a bit of custom finder code but cannot verify this as yet.

Is there a way to adjust the way total_pages is calculated? Perhaps using :count => parameter? I couldn't find how to use :count => documented anywhere to pursue this direction.

Comments and changes to this ticket

  • Mislav

    Mislav June 14th, 2007 @ 03:43 AM

    • State changed from “new” to “invalid”

    If you don't will_paginate to count your records, simply use the "total_entries" option. The value should be an integer and its presence makes the paginating finders skip the counting logic.

    Total page number is then being calculated like this:

    @total_pages   = (@total_entries / @per_page.to_f).ceil
    
  • Chris Wanstrath

    Chris Wanstrath June 14th, 2007 @ 03:43 AM

    This may or may not be fixed with changeset 258. Update the plugin and try again.

  • Wayne Seguin

    Wayne Seguin June 14th, 2007 @ 03:43 AM

    It turns out that passing:

    :count => { :select => "distinct o.id" }

    fixed the issue for us.

    Thanks for the response!

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Everyone's favorite Ruby library for pagination of practically anything!

People watching this ticket

Pages