Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Show 3 records, only advance 1
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jack Royal-Gordon  
View profile  
 More options Feb 12 2012, 11:59 am
From: Jack Royal-Gordon <jac...@pobox.com>
Date: Sun, 12 Feb 2012 08:59:29 -0800
Local: Sun, Feb 12 2012 11:59 am
Subject: Re: Show 3 records, only advance 1
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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.