diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-01-04 10:32:37 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-04 10:32:37 +0900 |
commit | a5a22c4ea142974117d6afbde68a8074617bda0c (patch) | |
tree | 01253c463ade943dd8c8cb65bfcd55c754c0571f /activerecord/lib/active_record/relation | |
parent | 912db8bd060c79fbbc9fd73e90b3920dff7bfd48 (diff) | |
parent | d237c7c72ccfd87302983669f83c8c90d2aec82e (diff) | |
download | rails-a5a22c4ea142974117d6afbde68a8074617bda0c.tar.gz rails-a5a22c4ea142974117d6afbde68a8074617bda0c.tar.bz2 rails-a5a22c4ea142974117d6afbde68a8074617bda0c.zip |
Merge pull request #34858 from albertoalmagro/make-rails-compatible-accross-ruby-versions
Make average compatible across ruby versions
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 3ef6e7928f..c2c4a5a882 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -401,7 +401,7 @@ module ActiveRecord case operation when "count" then value.to_i when "sum" then type.deserialize(value || 0) - when "average" then value.respond_to?(:to_d) ? value.to_d : value + when "average" then value&.respond_to?(:to_d) ? value.to_d : value else type.deserialize(value) end end |