PaginateAlphabetically
An easy way to paginate a list of ActiveRecord objects alphabetically by any given attribute.
Example
Model
class User < ActiveRecord::Base
paginate_alphabetically :by => :surname
end
Controller
class UsersController < ApplicationController
def index
@users = User.alphabetical_group(params[:letter])
end
end
View (haml example)
= alphabetically_paginate(@users)
%ul.users
- @users.each do |user|
%li= user.surname
Testing
The tests use a sqlite3 in-memory database to be able to run separately from your application.
rake test
Copyright © 2010 Eden Development, released under the MIT license