-
Notifications
You must be signed in to change notification settings - Fork 0
Troubleshooting
This is a FAQ on a number of common pitfalls seen on the Google group.
First make sure that you have the latest release of will_paginate. Each new release fixes a number of outstanding bugs. Check the installation instructions and see below how to find out which version do you have.
If these tips don’t help and you become sure you’ve found a bug, here is a list of open will_paginate bugs. Check if it’s already been reported and create a new ticket if it’s not (see Report bugs).
Read the installation instructions. Your application should either load the gem or have the plugin located in “vendor/plugins/will_paginate/” directory. To see if the library has been loaded, open “script/console” of your app and try the following lines:
>> defined? WillPaginate
>> [].paginate
>> ActiveRecord::Base.respond_to? :paginate
If any of these lines return false
or result in an error, will_paginate is not properly loaded in your app.
It’s easy to find out will_paginate version. Open “script/console” of your app and type:
>> require "will_paginate/version"
>> WillPaginate::VERSION::STRING
If “will_paginate/version” doesn’t exist, then you have a very old version of will_paginate and you should upgrade immediately (see Installation).
In newer versions, the `page_count’ method of WillPaginate::Collection class has been renamed to `total_pages’ for consistency. This broke some Sphinx and Ferret plugins for fulltext indexing in Rails because they were emulating WillPaginate::Collection when trying to be “will_paginate compatible”.
If you are indeed using 3rd party code like this, please update your Sphinx (or Ferret) plugin to the latest version or ask on their mailing lists about this error. Otherwise feel free to report this on our mailing list (top).
Not using Sphinx or Ferret but still getting this error? Make sure you action is using #paginate (Post.paginate), and not #find (Post.find) .
See Simple search for explanation of why this happens.
First inspect the URL. Let’s say that it looks like this:
http://example.com/posts?page=2
You can see that the default name for the page parameter in the URL is, unsurprisingly, “page”. You have to make sure that, in your controller, you pass that parameter to the paginating finder:
@posts = Post.paginate :page => params[:page], :order => 'created_at DESC'
If a wrong parameter is passed as :page
parameter, pagination will forever be “stuck” on page 1.
- Installation instructions
- API documentation
- Differences between v2.3 - v3.0
- Troubleshooting or Report bugs
- Simple search functionality
- Translating output (i18n)
- Join the Google group
- Browse the source code
- See the recent commits