muratguzel / letsrate

The best way to add rating capabilities to your rails application and your activerecord models.
http://letsrate.herokuapp.com
198 stars 234 forks source link

update_rate_average calculation mismatch in model.rb #7

Closed perrier closed 11 years ago

perrier commented 11 years ago

Hi!,

The function update_rate_average has a little issue in the calculation, average decrease while the quantity of votes increase.

Line 30 in letsrate/lib/letsrate/model.rb:
'a.avg = (a.avg + stars) / (a.qty+1)'

...should be: 'a.avg = (a.avg*a.qty + stars) / (a.qty+1)'

to take in account the number of votes that have the average in dividend... Maybe this calculation can be done in different way but with this it works.

Thanks!

jorgesilveira commented 11 years ago

Already solved!

muratguzel commented 11 years ago

Now, you can use the new version (letsrate 1.0.8)