I have a table of review records where one of the fields (rating, a number 1 to 5) is an integer and they are displayed as partials on their assigned venue show page.
How can I show on the venue show page the total of all the ratings from all its reviews divided by the number of reviews it has?
I get the total number of r开发者_高级运维eviews written for the venue with:
<%= @venue.reviews.count %>
Thanks for any help its much appreciated!
@venue.reviews.average(:rating)
精彩评论