Topic: On which page is the record with will_paginate

Hi there,

I'm facing a problem which I'm currently unable to solve ... so if anyone of you could give me a hint that would help me a lot.
What I do have is a paginated "table of contents" based on the great will_paginate plugin. Furthermore There is a use case in which I get find a record by it's name and display it. So for the paginated TOC to work properly, I need the page on which the found record is on. But how do I achive that?

Regards and thanks in advance,
Christian Weichel

Re: On which page is the record with will_paginate

Unfortunately this is difficult to do properly. It depends on the database engine you're using. If it's MySQL, check out this thread for some example queries to calculate the position a given record shows up in a query. After that you just need to do some math to determine the page number.

Railscasts - Free Ruby on Rails Screencasts

Re: On which page is the record with will_paginate

Wow, that was fast ...
As for now I'm using MySQL so the solution from the thread you pointed me to works for me.
Thank you very much