Every repository with this icon (
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | ||
| |
README | ||
| |
README.rdoc | ||
| |
Rakefile | ||
| |
init.rb | ||
| |
install.rb | ||
| |
lib/ | ||
| |
partials/ | ||
| |
tasks/ | ||
| |
test/ | ||
| |
uninstall.rb |
Simple and flexible pagination using named scopes and partials.
I didn’t like how will_paginate tried to infer the counting sql from the main query. Specifically, if I wanted to do eager loading, then the counting sql did unnecessary joins. I like keeping the counting sql separate from the query because it gives the user more control. It’s also more explicit and easier to understand what’s going. This entire plugin is extremely simple and easy to understand, thus easy to modify if you so choose.
Example
# model code
class Post < ActiveRecord::Base
pagination :per_page => 10
has_many :subscribers
end
# action code
def some_action
@posts = Post.active.latest.paginate(params[:page]).all(:include => :subscribers) # eager loading requires a join
post_count = Post.active.latest.count # no unnecessary join
@paginator = Post.paginator(params[:page], post_count)
end
# view code
<%= render_paginator(@paginator) %>
Installation
script/plugin install git://github.com/cjbottaro/paginate_izzle.git
Or if that doesn’t work…
git clone git://github.com/cjbottaro/paginate_izzle.git vendor/plugins/paginate_izzle mkdir -p app/views/shared cp vendor/plugins/paginate_izzle/partials/* app/views/shared/
More
This plugin is pretty flexible. You can specify a bunch of rendering options and/or write your own partial to render the widget. See the documentation for Paginator::DEFAULT_OPTIONS, Paginator#pages and _default_paginator.html.erb.
More examples to come on how to use the rendering options and how to create your own rendering partial.
Copyright © 2008 Christopher J. Bottaro <cjbottaro@alumni.cs.utexas.edu>, released under the MIT license








