I have code in my controller that is ranking albums by the highest average review rating (used code from this solution How to display highest rated albums through a has_many
You are not allowed to select reviews.id (selected implicitly through the wildcard *) without adding it to the GROUP BY clause or applying an aggregate function like avg(). The solution is to do one of the following:
* from your selectreviews.id to your group clausereviews.id explicitly and apply an aggregate function to it (e.g. sum(reviews.id)) * with the table-specific wildcard albums.*The second and third option do not make much sense in your scenario though. Based on your comment, I added option four.