# Help with :limit :ofset loop?

**URL:** <https://www.ruby-forum.com/t/help-with-limit-ofset-loop/110826>\
**Category:** Rails\
**Created:** [July 31, 2007, 11:56am UTC](https://www.ruby-forum.com/t/help-with-limit-ofset-loop/110826 "2007-07-31T11:56:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bxsitecover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6a8cbe/32.png) [@bxsitecover](https://www.ruby-forum.com/u/bxsitecover)\
**Post date:** [July 31, 2007, 11:56am UTC](https://www.ruby-forum.com/t/help-with-limit-ofset-loop/110826/1 "2007-07-31T11:56:10Z")

</div>

This is the code in my model to display 10 records from a db table at  
a time.

def self.find\_5  
find(:all,  
:order =\> ‘id’,  
:limit =\> 5, :offset =\> 0)  
end

I want to make a loop so that say if my table contains 45 records and  
the limit is find 5 records and the offset changes on a weekly basis  
and one day overlaps my last record it will continue and pull from the  
first record and so on.

Thank you for reading.
