I\'m setting up a simple ruby/rails app where users can review albums. On an album\'s show page I average all the user reviews associated with that album through this code in my
try @albums = Album.joins(:reviews).select("album.id, avg(reviews.rating) as average_rating).group("album.id").order("average_rating DESC")
I extrapolated it from: Ruby on Rails: Order users based on average ratings with most reviews?
Update:
try this instead: @albums = Album.joins(:reviews).select("*, avg(reviews.rating) as average_rating").group("albums.id").order("average_rating DESC")