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.
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:
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:
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?
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.