@stories = Story.tally( :conditions => {:votes => {:vote => true}}).paginate :page => params[:page], :per_page => 8
After several attempts, i tried putting this condition, and it seems as if the data are sorted according to the number of vote_for it...
It has already included the association table in the plugin perhaps.
Showing posts with label Plugins. Show all posts
Showing posts with label Plugins. Show all posts
Friday, June 12, 2009
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 %>
Subscribe to:
Posts (Atom)