Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

If average value from DB is 0, make sure to convert it to a 0.0 float…

… before calling #to_d on it [#1346 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information...
commit a7f920f674d234f281d2491ebe6d74710a79e663 1 parent 1767c4b
@metaskills metaskills authored josh committed
Showing with 1 addition and 1 deletion.
  1. +1 −1  activerecord/lib/active_record/calculations.rb
View
2  activerecord/lib/active_record/calculations.rb
@@ -286,7 +286,7 @@ def type_cast_calculated_value(value, column, operation = nil)
case operation
when 'count' then value.to_i
when 'sum' then type_cast_using_column(value || '0', column)
- when 'avg' then value && value.to_d
+ when 'avg' then value && value.to_f.to_d
else type_cast_using_column(value, column)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.