wazery / ratyrate

:star: A Ruby Gem that wraps the functionality of jQuery Raty library, and provides optional IMDB style rating.
http://ratingmoviestore.herokuapp.com
237 stars 120 forks source link

How to get average from all users #11

Open wazery opened 10 years ago

wazery commented 10 years ago

Issue by legos Sunday Apr 07, 2013 at 20:44 GMT Originally opened as https://github.com/muratguzel/letsrate/issues/26


How would I get the average rating from all users for each attribute and also the average overall rating from all attributes? Also, is it possible to show a numerical value instead of the stars?

wazery commented 10 years ago

Comment by joshmn Monday May 27, 2013 at 04:36 GMT


I'm going to fork this and add these features.

dguillot commented 9 years ago

What is the method to get an average score from all users for an attribute?

wlodi83 commented 9 years ago

hi,

you can try following:

@game.average("rating").avg

where "rating" is dimension defined in Game model in this case

Puja-K commented 9 years ago

hi,

I could not get @game.average("rating").avg to work. when I use this, it gives me an error undefined method `avg' for nil:NilClass

I am looking for the same method. Any solutions.

Thanks, Puja

wlodi83 commented 9 years ago

What is your defined dimension in User model? Is it "rating" ?

exitosyf2 commented 7 years ago

Use this <%= package.average("user_rating").present? ? package.average("user_rating").avg : 0 %> @Puja-K