This post originated from an RSS feed registered with Ruby Buzz
by Red Handed.
Original Post: Officialized PaginationHelper
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Regarding the story last week on the PaginationHelper for Rails, its author has updated the code and enhanced documentation. You can still paginate using the Paginator class directly or the helper can automatically paginate.
To automate pagination for all controllers:
class PersonController < ApplicationController
helper :pagination
model :person
paginate :people, :order_by => 'last_name, first_name',
:per_page => 20
end
To automate pagination for a single controller action:
def list
@person_pages, @people =
paginate :people, :order_by => 'last_name, first_name'
end
Sam Stephenson has really done a great job with this release, good of him to take the suggestions from the Paginator I offered last week and mix them up with the variety of other contributions offered by users of this fine Rails helper.