In rails3, almost all query interface change to be lazyloading now, but 'will_paginate' will hit the database imediately after you use the 'paginate' method. How can I make it lazyload records?
A:
I have make it by rewriting many code in will_paginate, It's really hard for will_paginate to lazy load, because will_paginate has a core class 'WillPaginate::Collection' which is a subclass of 'Array'.(I don't like this class )
All results generated by 'paginate' method will return a Collection instance, so it will force the 'ActiveRecord::Relation' object into an 'Array' which will force the Relation hit the database imidiately.
Croplio
2010-08-23 09:52:26