Browse the Ruby on Rails Community.

You are here: Browse Railsplugins Cheap Pagination

Cheap Pagination

Uses an API similar classic paginate that was originally in rails. If you have a complex finder or association you need to deal with, you can pass it as a block instead of using options. The pagination concept is based on Jamis Buck’s technique for “Poor-man’s pagination”.

  • http://weblog.jamisbuck.org/2007/2/28/poor-man-s-pagination

Example

app/controllers/posts_controller.rb

def index
  paginate :posts, :per_page => 25
end

Got a complex finder or association?

def index
  paginate :posts do |options|
    @user.posts.find(:all, { :conditions => "published = 1" }.merge(options))
  end
end

app/views/posts/index.html.erb

<%= pagination_links %>

Copyright© 2007 Joshua Peek, released under the MIT license


Homepage: http://projects.wh.joshpeek.com/browser/plugins/cheap_pagination