aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-11-11 10:22:09 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2008-11-11 10:22:09 -0800
commit5d2b5ba23e93f4fd4992c418c9bb2fc721df4206 (patch)
treefea6d6473015f03499388e0a60ee13680179695c /activerecord
parent17ac2a248282ed34b694ebd4fc651d6a0eb1a23d (diff)
parentcbb38bbdba0f7cfb628a0f8716e79d0d079fd7bf (diff)
downloadrails-5d2b5ba23e93f4fd4992c418c9bb2fc721df4206.tar.gz
rails-5d2b5ba23e93f4fd4992c418c9bb2fc721df4206.tar.bz2
rails-5d2b5ba23e93f4fd4992c418c9bb2fc721df4206.zip
Merge branch 'master' into testing
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/calculations.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb
index dd90580b3d..6f4e02b430 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_f.to_d
+ when 'avg' then value && (value == 0 ? 0.0.to_d : value.to_d)
else type_cast_using_column(value, column)
end
end