Cheap Pagination
- Filed under Pagination
- Developed by josh
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 (c) 2007 Joshua Peek, released under the MIT license
Last updated: August 23, 2007 20:20


