Topic: count and display results
hi, i'm newbie for rails. i need to display the results from counting data in the tables.
when i test select syntax in mysql query browser, the result run correctly.
then i created method in model to count customers
return Customer.count_by_sql("select count(*) from customers, managers where customers.manager_id = managers.id group by manager_id")
after that, i coded in view
<%= Manager.count_customer %>
but my web application display the results only first record of the table and display the same result all managers. you know manager has many customers but i got all managers has the same customer amount.
i'm sure that i did somethings wrong.
how to fix that?
Last edited by maya (2006-11-29 14:25:49)