The key lies in how paginate pages the data. For an ActiveRecord source, it generates the following ARel modifiers:
offset how many records to skip before starting collection
limit how many records to include in the collection
will_paginate's default processing is to use offset => (pager.offset) and limit => (pager.per_page), but what you want is offset => (pager.page - 1), limit => (pager.per_page). This can be accomplished by performing manual paging, as documented with WillPaginate::Collection:
# Just like +new+, but yields the object after instantiation and returns it
# afterwards. This is very useful for manual pagination:
#
# @entries = WillPaginate::Collection.create(1, 10) do |pager|
# result = Post.find(:all, :limit => pager.per_page, :offset => pager.offset)
# # inject the result array into the paginated collection:
# pager.replace(result)
#
# unless pager.total_entries
# # the pager didn't manage to guess the total count, do it manually
# pager.total_entries = Post.count
# end
# end
There may be an easier way to accomplish this -- let's see what others say.
On Feb 10, 2012, at 7:36 PM, Rembrant wrote:
> Hello,
> I want to show (3) records per page but when the next or previous
> buttons are clicked I only want one record at a time to advance.
> e.g.
> | 1 2 3 | 4 5
> becomes
> 1 | 2 3 4 | 5
> Any help would be greatly appreciated.
> Many thanks,
> Rembrant
> --
> You received this message because you are subscribed to the Google Groups "will_paginate" group.
> To post to this group, send email to will_paginate@googlegroups.com.
> To unsubscribe from this group, send email to will_paginate+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/will_paginate?hl=en.