aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorDaniel E. Garcia Shulman <vinagrito@users.noreply.github.com>2016-11-02 21:45:54 +0200
committerSean Griffin <sean@seantheprogrammer.com>2016-11-02 15:45:54 -0400
commit032ab94332fd5496c5af627bc36445cea3ba476a (patch)
treed05d12ef989a1bcee943da587227b8b0b72c8c42 /activerecord/lib/active_record/associations
parent7b0b119c500d45b9bc751e5346ad5f316dddcc29 (diff)
downloadrails-032ab94332fd5496c5af627bc36445cea3ba476a.tar.gz
rails-032ab94332fd5496c5af627bc36445cea3ba476a.tar.bz2
rails-032ab94332fd5496c5af627bc36445cea3ba476a.zip
Fixes TypeError Exception when cache counter value equals nil (#26940)
* Fixes TypeError when cache counter value equals nil * Test case for counter cache on unloaded has_many association
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/has_many_association.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb
index d1d0cc4c49..742cd25509 100644
--- a/activerecord/lib/active_record/associations/has_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_association.rb
@@ -72,7 +72,7 @@ module ActiveRecord
# the loaded flag is set to true as well.
def count_records
count = if reflection.has_cached_counter?
- owner._read_attribute reflection.counter_cache_column
+ owner._read_attribute(reflection.counter_cache_column).to_i
else
scope.count
end