Skip to content

Instantly share code, notes, and snippets.

@dstarh
Created February 19, 2014 20:50
Show Gist options
  • Save dstarh/9101246 to your computer and use it in GitHub Desktop.
Save dstarh/9101246 to your computer and use it in GitHub Desktop.
average = (50.0 + 75.0 + 90.0) / 3.0 => 71.66666666666667 (14 decimal places)
average = ratings.average(:rating).to_f => 71.6666666666667 (13 decimal places)
:rating is a double in postgres.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment