Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

handling an out of range page number

#125

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)

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

State: resolved
Milestone: none
Assigned to: Mislav Mislav

Activity

  1. Fjan
    Fjan
    • Assigned user changed from Chris Wanstrath to Mislav

    October 5th, 2007 @ 08:06 PM

  2. Mislav
    Mislav
    • 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.

    October 6th, 2007 @ 08:44 PM

  3. Mislav
    Mislav

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

    October 6th, 2007 @ 08:44 PM

  4. Fjan

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.