Pagination: Last Page

Hi Folks

is there any way to link to the last page of a paginated list, if the
number of pages is not available in this moment? For example a forum
with topic and replies. I'd like to link to the last page of the
replies, but I don't know how many pages there are in the forum view?
I'm using mislav-will_paginate for pagination.

Thank you in advance!

i had the same problem. some people already asked this feature to
be added to will_paginate, apparently the developer doesn't think
it is a good idea. check this:

http://groups.google.com/group/will_paginate/browse_thread/thread/9c4ff183a4271bde/3f71f7dc31a54767

for my projects i made an extension to make will_paginate accept
:page => :last.

Patrick Heneise wrote:

PP Junty wrote:

i had the same problem. some people already asked this feature to
be added to will_paginate, apparently the developer doesn't think
it is a good idea. check this:

http://groups.google.com/group/will_paginate/browse_thread/thread/9c4ff183a4271bde/3f71f7dc31a54767

for my projects i made an extension to make will_paginate accept
:page => :last.

Thanks for this hint. Too bad Mislav doesn't accept this point. Do you
have a link for your extension?

Thank you!

ok, i made a little plugin with this functionality, it is attached.
definitely not a pro solution but may be useful. could you test
it and see if it is working? if it is i could publish it on github.
this plugin also alter another behavior that i find annoying, which is:
when you request a page greater than the total pages will_paginate
returns an empty page. that happens specially when the last item of
a page is deleted. the extension will always return the last page in
this case.

Patrick Heneise wrote:

Thanks for this hint. Too bad Mislav doesn't accept this point. Do you
have a link for your extension?

Thank you!

Attachments:
http://www.ruby-forum.com/attachment/3796/will_paginate_last.zip

just a correction.
by
"that happens specially when the last item of a page is deleted."
i meant
"that happens specially when the last page has only one item and the
item is deleted."

you should use blank? instead of nil? because even the original
will_paginate will throw an error if you pass an empty string.
and you should not rely on what you receive in the param :page as
a user could manually alter the url to some strange value. what
i do is to have a parse method that ensure that will_paginate is
getting a valid page number, that is why i didn't bother throwing
a more informative error message, i'll see if it can be improved.