KANTENA Paris France
May 2009
1 - Purpose
PROGRESS ADAPTER is for use when DBMS engine doesn't support LIMIT and OFFSET SQL instructions,
as PROGRESS DBMS don't (until v 10.2 ).
With such DBMS and rails you load all records and instantiate each object for , which can be such longer !
Tough , no pagination is possible .
With this ProgressAdapter module , you easily can !
2 - Install
Install plugin : script/plugin git://github.com/kkantena/progress_adapter.git
3 - Use it !
Add "include ProgressAdapter" in models where you need it.
You can use ActiveRecord::Base.find as usual , and can now pass two more keys :
:page =>
:per_page => < number of object instanciation records you want>
To get number of records : number_of_records method
To get number of pages : number_of_pages method
Example :
class Foo < ActiveRecord::Base
include ProgressAdapter
def list
list = find :all , :page => 4 , :per_page => 10
nb_records = number_of_records
nb_pages = number_of_pages
[nb_records,nb_pages,list]
end
end