"This is an excellent gem and is a good display of using ruby correctly for accomplishing the concept of pagination." (found on [1], credited to [2])
"You instantiate a Paginator object, telling it how many records there are and how many you’d like per page. You also pass a block that will be used to return the records for a page, given the record offset (and the number of records per page—which you just passed into the constructor—as a convenience)." ([3])
PER_PAGE = 20
@pager = ::Paginator.new(Foo.count, PER_PAGE) do |offset, per_page|
Foo.find(:all, :limit => per_page, :offset => offset)
end
@page = @pager.page(params[:page])