classic pagination with custom finders/sql

If you're on a recent version of Rails, it would be best to replace
the 'active' method above with a named scope:

named_scope :active, :conditions => { :state => 'active' }

Then you can use as a base to find only active users. Note
that the scope supports all the
various find methods, ie:, :order => 'last_name', :limit => 5)

will work. See the docs at