Wednesday, February 24, 2010

will_paginate gem gets stuck on the first page.


Problem


The latest version of will_paginate ignores the page parameter using Rails > 2.2


recs = User.paginate, :page => 1 , :per_page => 1
recs2 = User.paginate, :page => 2 , :per_page => 1

assert_not_equal recs.first, recs2.first



Solution

Using the 'order' parameter fixes the problem:



recs = User.paginate, :page => 1 , :per_page => 1 , :order => 'username'
recs2 = User.paginate, :page => 2 , :per_page => 1 , : order => 'username'

assert_not_equal recs.first, recs2.first

No comments:

Popular Articles