How can I get FOUND_ROW()s from an active record object in rails?

Posted by Justin Tanner on Stack Overflow See other posts from Stack Overflow or by Justin Tanner
Published on 2010-06-18T00:54:21Z Indexed on 2010/06/18 8:03 UTC
Read the original article Hit count: 191

Filed under:
|

When querying the database with:

@robots = Robot.all(:limit => 50, :offset => 0)

What is the best way to get the total number of rows without the :limit?

In raw MySQL you could do something like this:

SELECT SQL_CALC_FOUND_ROWS * FROM robots LIMIT 0, 50
SELECT FOUND_ROWS();

© Stack Overflow or respective owner

Related posts about mysql

Related posts about ruby-on-rails