On page 172 of the book, we talk about Pagination. Pagination is a good thing. As a rule, don’t return more results from the database than you need to for a given purpose.
In the sample application, we use Rails’ built-in Paginator, but with the caveat that it might be slated for future removal from the framework. Alas, that day has come. In Rails 2.0, pagination is no more. Why? Well, as I mentioned in the book, a lot of folks feel that pagination is too domain-specific to be part of the framework.
You can install the classic_pagination plugin, which is the extracted code from Rails, rolled into a plugin. This is what we used in the book. Installation is the same as for any plugin:
./script/plugin install svn://errtheblog.com/svn/plugins/classic_pagination
That’ll get you up and running with the examples in the book. This has bitten at least one reader already. Read up on the thread on the book’s mailing list
Enter: will_paginate
Pagination was removed from Rails because it was deemed outside the scope of the framework. This is good. Removing a feature like this is usually a catalyst for the emergence of better alternatives. Out of the handful of pagination plugins currently circulating, my favorite is will_paginate:
http://errtheblog.com/post/4791 http://require.errtheblog.com/plugins/browser/will_paginate/README?format=txt
This is from will_paginate’s README:
# app/controllers/posts_controller.rb
@posts = Post.paginate :page => params[:page]
# app/views/posts/index.html.erb
<p>Handful of posts coming up</p>
<%= render :partial => 'post', :collection => @posts %>
<p>Now let's render us some pagination!</p>
<%= will_paginate @posts %>
Note that will_paginate’s interface is different than that of classic pagination, so it’s not a drop in replacement. Still, if you read the examples in the README, you should be able to figure it out in no time!

