# Can I get meaningful page links using will\_paginate?

**URL:** <https://www.ruby-forum.com/t/can-i-get-meaningful-page-links-using-will-paginate/189197>\
**Category:** Rails\
**Created:** [May 26, 2010, 3:47pm UTC](https://www.ruby-forum.com/t/can-i-get-meaningful-page-links-using-will-paginate/189197 "2010-05-26T15:47:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![RonPhillips](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@RonPhillips](https://www.ruby-forum.com/u/RonPhillips)\
**Post date:** [May 26, 2010, 3:47pm UTC](https://www.ruby-forum.com/t/can-i-get-meaningful-page-links-using-will-paginate/189197/1 "2010-05-26T15:47:17Z")

</div>

Let’s say you search for “dengue fever.” Your search returns 137  
pages, ordered by date, but labeled with a page number. You decide to  
look at articles written just before and after the Haitian earthquake  
(Jan 12, 2010). Should you start on page 65, or 125?

That’s nuts.You should have the choice of 137 pages with the date of  
the first post on the page displayed as the page link. Start on page  
“Jan 7, 2010” and read forward. That’s easy. Jakob Nielsen agrees with  
me, so there! [rooh.it](http://rooh.it/PageNumbersMeaningless)

I can do that with Bruce William’s Paginator gem (http://  
[groups.google.com/group/rubyonrails-talk/browse\_frm/thread/](http://groups.google.com/group/rubyonrails-talk/browse_frm/thread/)  
7267090150ef6cc7/5c75c93d0324f356). However, will\_paginate is the de  
facto standard.

How do we get semantically-meaningful page links using will\_paginate?  
Or should I stick with the paginator gem?

Ron

---

<div class="post-metadata">

**Author:** ![RonPhillips](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@RonPhillips](https://www.ruby-forum.com/u/RonPhillips)\
**Post date:** [May 26, 2010, 5:07pm UTC](https://www.ruby-forum.com/t/can-i-get-meaningful-page-links-using-will-paginate/189197/2 "2010-05-26T17:07:29Z")

</div>

On May 26, 2:46 pm, RonPhillips [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I can do that with Bruce William’s Paginator gem (http://  
> [groups.google.com/group/rubyonrails-talk/browse\_frm/thread/](http://groups.google.com/group/rubyonrails-talk/browse_frm/thread/)  
> 7267090150ef6cc7/5c75c93d0324f356). However, will\_paginate is the de  
> facto standard.
> 
> How do we get semantically-meaningful page links using will\_paginate?  
> Or should I stick with the paginator gem?

You can supply a custom LinkRenderer class to will\_paginate, which  
controls how page links are displayed. You might need to do some  
messing around in order to get the data for each page link - i think  
the link renderer is given the will paginate collection object and the  
fact that this is the link for page 23. Does it matter that if there  
were suddenly a lot of articles about a given subject that you’d then  
have several page links all with the same title ?

Fred

---

<div class="post-metadata">

**Author:** ![RonPhillips](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@RonPhillips](https://www.ruby-forum.com/u/RonPhillips)\
**Post date:** [May 26, 2010, 6:12pm UTC](https://www.ruby-forum.com/t/can-i-get-meaningful-page-links-using-will-paginate/189197/3 "2010-05-26T18:12:00Z")

</div>

RonPhillips wrote:

> That’s nuts.You should have the choice of 137 pages with the date of  
> the first post on the page displayed as the page link. Start on page  
> “Jan 7, 2010” and read forward. That’s easy. Jakob Nielsen agrees with  
> me, so there! [rooh.it](http://rooh.it/PageNumbersMeaningless)

What I think is even more nuts is to have to slog through 137 pages of  
results without having a decent way to filer that down to just a few  
pages at most.

For example. I very rarely make it past about page 3 or 4 of a Google  
search result set. I’d never make it to page 125.

---

<div class="post-metadata">

**Author:** ![RonPhillips](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@RonPhillips](https://www.ruby-forum.com/u/RonPhillips)\
**Post date:** [May 27, 2010, 1:25pm UTC](https://www.ruby-forum.com/t/can-i-get-meaningful-page-links-using-will-paginate/189197/4 "2010-05-27T13:25:07Z")

</div>

Exactly! If you search for some term, and then specify an ordering of  
the results, the pages should be labeled with your ordering, not  
numbers.

Let’s say you search for “dengue fever” and then order by author. The  
page links should show the name of the author of the first article on  
the page. Then it’s easy to home in on Robert Abernathy, followed by  
Robert W., then Frederick C… Why make us guess that “Walker”  
is going to be around 125, then click from page to page? Just label  
the pages with the sorting field.

Ron

---

<div class="post-metadata">

**Author:** ![RonPhillips](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@RonPhillips](https://www.ruby-forum.com/u/RonPhillips)\
**Post date:** [May 27, 2010, 2:02pm UTC](https://www.ruby-forum.com/t/can-i-get-meaningful-page-links-using-will-paginate/189197/5 "2010-05-27T14:02:49Z")

</div>

RobertWalker wrote:

What I think is even more nuts is to have to slog through 137 pages of  
results without having a decent way to filer that down to just a few  
pages at most.

For example. I very rarely make it past about page 3 or 4 of a Google  
search result set. I’d never make it to page 125.

RonPhillips wrote:

> Exactly! If you search for some term, and then specify an ordering of  
> the results, the pages should be labeled with your ordering, not  
> numbers.
> 
> Let’s say you search for “dengue fever” and then order by author. The  
> page links should show the name of the author of the first article on  
> the page. Then it’s easy to home in on Robert Abernathy, followed by  
> Robert W., then Frederick C… Why make us guess that “Walker”  
> is going to be around 125, then click from page to page? Just label  
> the pages with the sorting field.
> 
> Ron

---

<div class="post-metadata">

**Author:** ![RonPhillips](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@RonPhillips](https://www.ruby-forum.com/u/RonPhillips)\
**Post date:** [May 27, 2010, 1:18pm UTC](https://www.ruby-forum.com/t/can-i-get-meaningful-page-links-using-will-paginate/189197/6 "2010-05-27T13:18:05Z")

</div>

Ok, I am thinking search by title, then the results are sorted by  
date, so I want to label pages by date.  
There’s a series of screenshots at  
[![Imgur](https://live.staticflickr.com/3936/15363054858_f02f709888.jpg "tst\_44311") ](https://www.flickr.com/photos/21409535@N08/)  
to show what I mean.

If I expect lots of search results in a field to be identical, then I  
like to index by some other logical ordering. If that’s not possible,  
then “title” must be the only identifier that is human-readable. In  
that case, how does the user decide which one he wants even after he  
searches?

Ron

On May 26, 11:05 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![RonPhillips](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@RonPhillips](https://www.ruby-forum.com/u/RonPhillips)\
**Post date:** [May 27, 2010, 2:07pm UTC](https://www.ruby-forum.com/t/can-i-get-meaningful-page-links-using-will-paginate/189197/7 "2010-05-27T14:07:56Z")

</div>

RonPhillips wrote:

> Ok, I am thinking search by title, then the results are sorted by  
> date, so I want to label pages by date.  
> There’s a series of screenshots at  
> [tst\_44311 | Flickr](http://www.flickr.com/photos/21409535@N08/)  
> to show what I mean.
> 
> If I expect lots of search results in a field to be identical, then I  
> like to index by some other logical ordering. If that’s not possible,  
> then “title” must be the only identifier that is human-readable. In  
> that case, how does the user decide which one he wants even after he  
> searches?
> 
> Ron

Sorry for the crazy posting. I’d just never realized that the Google  
Group is actually a reflection of this forum (I mostly lurk.)

Anyway, the flickr screenshots will show what I mean, I hope. How does  
one  
do that with will\_paginate?

Ron

---

<div class="post-metadata">

**Author:** ![RonPhillips](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@RonPhillips](https://www.ruby-forum.com/u/RonPhillips)\
**Post date:** [May 27, 2010, 8:56pm UTC](https://www.ruby-forum.com/t/can-i-get-meaningful-page-links-using-will-paginate/189197/8 "2010-05-27T20:56:00Z")

</div>

Well, I still think it’s silly to make users play “guess the page  
number,” so here’s how you can make nicely labeled page links with  
Paginator.

In your controller:

[http://pastie.org/980498](http://pastie.org/980498)

and in your view:

[http://pastie.org/980519](http://pastie.org/980519)

Perhaps this isn’t so easy using will\_paginate. So, another question: Is  
there any disadvantage to using Paginator?

Ron
