method
offset
v5.0.0.1 -
Show latest stable
- Class:
ActiveRecord::QueryMethods
offset(value)public
Specifies the number of rows to skip before returning rows.
User.offset(10) # generated SQL has "OFFSET 10"
Should be used with order.
User.offset(10).order("name ASC")
1Note
doesn't work directly off a class.
for some reason this method only works on relation objects, not directly on an AR class.
# doesn't work
User.offset(3).limit(1)
# does work
User.limit(1).offset(3)
there's an closed ticket for this here http://rails.lighthouseapp.com/projects/8994/tickets/5688-modeloffsetxlimitx-unknown-offset-method-exception and should be resolved in the next release of rails.