How to count the number of records in a table...

Posted by paul Wed, 28 Sep 2005 10:30:55 GMT

Want to find out how many records there are in a table?

You could do a table.<a href="http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M000674">find_by_sql </a> "select count(*) from table",

You could get all the records from the table and then count them, say records = table.find(:all).

Or you could do count = table.count.

How cool is that!