[Rails] Query Offset Parameter problem

Doug Meharry doug at dmeharry.com
Wed Aug 9 00:14:07 GMT 2006


Greetings,

I'm trying to make a simple logging application that just displays the 
last few rows of information in the log.  In order to do this, I am 
trying to use the ":offset" option for find.  However, I am not getting 
the results I expect.

For testing purposes, the query is being run against a table (MySQL) 
that contains 11 records.  According to the RoR documentation, when I 
use the :offset parameter as shown below, I expect to get back 6 records 
instead of 11.  Am I just not reading the documentation correctly?

    # This should return all rows in the table after the fifth row
    @transactions = Transaction.find(:all, :offset => 5 )

    # Should show 6 if the total rows are 11
    puts "TOTAL ROWS RETURNED IS: " + @transactions.size.to_s

Thanks in advance for any insight or help.

Doug

-- 
Posted via http://www.ruby-forum.com/.


More information about the Rails mailing list