kevin wrote:> I am trying to find the count of rows on a table. If I do a
> result= Table.find_by_sql ("select count(distinct id) ......
>
> It returns an array of Table with Hashes of "select count(distinct
id)"
> making accessing it a pain
> result[0][''select count(distinct id)'']
>
> It seems easier to return all the rows and do a .length on the result
> Array.
>
> What is the proper way to do this ?
There is a Table.count_by_sql class method that you can use.
http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M000726
Regards,
Blair
--
Blair Zajac, Ph.D.
<blair@orcaware.com>
Subversion training, consulting and support
http://www.orcaware.com/svn/