Ruby on Rails activerecord find average in one sql and Will_Paginate
Posted
by Darkerstar
on Stack Overflow
See other posts from Stack Overflow
or by Darkerstar
Published on 2010-03-28T07:10:37Z
Indexed on
2010/03/28
7:13 UTC
Read the original article
Hit count: 280
Hi all
I have the following model association: a student model and has_many scores.
I need to make a list showing their names and average, min, max scores. So far I am using student.scores.average(:score) on each student, and I realise that it is doing one sql per student. How can I make the list with one joined sql?
Also how would I use that with Will_Paginate plugin?
Thank you
© Stack Overflow or respective owner