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 User.active as a base to find only active users. Note
that the scope supports all the
various find methods, ie:

User.active.find(:all, :order => 'last_name', :limit => 5)

will work. See the docs at http://api.rubyonrails.org/classes/ActiveRecord/NamedScope/ClassMethods.html#M002120