Tuesday, June 9, 2009

Pagination

Pagination is used tomanage the population data in a single view such as having..


1 | 2 | 3 | next...


The complete how-tos are at http://wiki.rubyonrails.org/howtos/pagination or page 521 Pragmatic Agile Web Development with Rails 3rd Edition



.paginate is similar to .find but it's able to support the argument for :page => params[:page]



It is also possible to chain the pagination. Like using vote_fu's tally,


@users = User.tally().paginate :page => params[:page], :per_page => 8, :order => "name"



In the view, to have the 1,2,3,next etc...


this code needs to be added <%= will_paginate @models %>

0 comments:

Post a Comment