#125 ✓resolved
Fjan

handling an out of range page number

Reported by Fjan | October 5th, 2007 @ 08:06 PM

If the user deletes the last item on the last page of a will_paginated list, the total number of pages will decrease by one. Therefore the next page to be displayed will have the page parameter out of range and and the page will be empty, even if there are other pages left. In my opinion a nicer behavior would be to show the last page instead.

I solved it by adding this after line 53 of collection.rb
@current_page = @total_pages if @total_pages < @current_page it also means that the two count queries in finder.rb have to move to take place before the find query (so the optimization of not having to do a count on the last page gets lost)

Comments and changes to this ticket

  • Mislav

    Mislav October 6th, 2007 @ 08:44 PM

    • State changed from “new” to “resolved”

    In [393] I have added an "out_of_bounds?" method that returns true in conditions you've described. You can use it to decide what to do in your controllers or what to display in the view when the page requested doesn't exists. I will not make any guesses, so adjusting the page number to the last page is out of the question.

  • Mislav

    Mislav October 6th, 2007 @ 08:44 PM

    Blah, Lighthouse didn't pick up changeset 393 properly ... see it here: http://plugins.require.errtheblo...

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