github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

cjbottaro / paginate_izzle

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 3
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Simple and flexible pagination using named scopes and partials. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

installation instructions 
cjbottaro (author)
Tue Jul 15 20:02:50 -0700 2008
commit  2b296e9cea37cf4c50b0e607085252b575095d6a
tree    fd4f05d29da326722d9107959c8e80e73b3f0ccc
parent  d5c644604b2e903cb8cfff864c426556920a1ccb
paginate_izzle /
name age
history
message
file MIT-LICENSE Loading commit data...
file README
file README.rdoc
file Rakefile
file init.rb
file install.rb
directory lib/
directory partials/
directory tasks/
directory test/
file uninstall.rb
README.rdoc

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

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server