Ruby on Rails - Paginating

Well, I have moved on from Rails 1.2 to Rails 2.0 (actually rails 2.0.2 as of 6/2008) and lo (and behold) pagination is no longer part of the standard rails setup. Of course, all my rails projects use pagination, so this means that everything is broken till I either do away with pagination or get with the new program.

The new program is the will_paginate gem, which I install using gem install as shown below. This must be done as root because it wants to write into /usr/lib/ruby/gems/1.8/cache (alternately I could change permissions on all or part of the gems directory).

su
gem install mislav-will_paginate --source http://gems.github.com/
Bulk updating Gem source index for: http://gems.github.com/
Successfully installed mislav-will_paginate-2.3.2
Installing ri documentation for mislav-will_paginate-2.3.2...
Installing RDoc documentation for mislav-will_paginate-2.3.2...

After this, I go into each of my rails projects and edit config/environment.rb and after the Initializer block add:

require 'will_paginate'

Now a vital step: restart the web server. The symptom of not doing this is the paginate method will be found missing.


Feedback? Questions? Drop me a line!

Ruby on Rails notes / tom@mmto.org