2008年5月12日 星期一

paginate

divide large collections into pages

ex:
in the controller:
def  car_list
     @car_pages,  @cars = paginate ( :cars,  :order_by => 'name')
end
@car_pages is a paginator object.
@cars contain 10 rows.  ( default is 10 rows)

in the view:
table
  for car in @cars
       tr  td  car.name  td  tr
  end
table
hr
   pagination_links(@car_pages) 
hr
pagination_links  show the current page, two page numbers on either side of current page, first page & last page 

沒有留言: