diff options
author | Ken Collins <ken@metaskills.net> | 2008-11-07 20:39:06 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-11-07 20:39:06 -0600 |
commit | a7f920f674d234f281d2491ebe6d74710a79e663 (patch) | |
tree | cd0935e92534709c084ce9033d07ca98b5905d1a /activerecord/lib/active_record | |
parent | 1767c4b2da21379862a9ab1a4316d8da6b820a2a (diff) | |
download | rails-a7f920f674d234f281d2491ebe6d74710a79e663.tar.gz rails-a7f920f674d234f281d2491ebe6d74710a79e663.tar.bz2 rails-a7f920f674d234f281d2491ebe6d74710a79e663.zip |
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>
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/calculations.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb index 5e33cf1bd4..dd90580b3d 100644 --- a/activerecord/lib/active_record/calculations.rb +++ b/activerecord/lib/active_record/calculations.rb @@ -286,7 +286,7 @@ module ActiveRecord 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 |