This project is archived and is in readonly mode.

#2191 ✓invalid

Missing Info for ActiveRecord::Base#find option ':offset'

Reported by collink | March 10th, 2009 @ 05:28 AM | in 2.x

This evening I was tripped up by the way :offset works in ActiveRecord::Base#find. I was under the impression that you could just specify an offset and get all other records. The documentation states: ":offset - An integer determining the offset from where the rows should be fetched. So at 5, it would skip rows 0 through 4.".

In reality, you're required to specify a :limit as well. The way I got around this was by setting the limit to 'current_user.mymodels.count'.

I just wanted to point out that it's not documented that :limit is required for :offset to work. I actually had to go into the active record code to see why it wasn't working.

Comments and changes to this ticket

  • Pratik

    Pratik March 10th, 2009 @ 11:57 AM

    • Assigned user set to “Pratik”
    • State changed from “new” to “invalid”

    This is not really an Active Record issue, but just the way SQL works.


  • collink

    collink March 10th, 2009 @ 02:43 PM

    I didn't say it was an active record issue...but, in my opinion, it's worth documenting that :limit is required for :offset to work. In the docs on, it fails to mention that :limit is required.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket