activerecord-precount 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 462619d22d3bb8cbc486321638ba93bf37f67495
4
- data.tar.gz: d208201ce3549375e459fea3dba479b21e60c17d
3
+ metadata.gz: 558ab186a4ad75d87bd48d8035248b0a72170a33
4
+ data.tar.gz: 41746e4e827dfa0bb315730e0827682efef19072
5
5
  SHA512:
6
- metadata.gz: 15b8082a44e4a542d9033daa594dd8987f709d0306a666c6d1c3ff3a86e5d7926cf79fd3e6758713f4ce52fbf60b17611b9466d422d0bdace802a91f5d223b59
7
- data.tar.gz: 5e59714fc6686f6b8baf927bbe199e1480e762363fe84257ac409cf21d347f1d2b89e6edf05286e3f64b87cfd180eea7544509eb5b37f85e3d5746ef837345ca
6
+ metadata.gz: 03436420d1477fe170c6768e9b06f4c4b9ced3bd4ed4c91584023d00a88f789c8d204cab60701b3f3e8f0ee6027626b47ab62ca3c80581414b0e613ff0f61f4d
7
+ data.tar.gz: 6c7ce07a028ff757ba67fe6620de75204fa67c5d29f503569839c412890a412996c9e2345938b5fabb763339d27a6f41a7e7ee8eca1e16bfa82c17dfe37e697d
@@ -7,8 +7,8 @@ module ActiveRecord
7
7
  counter_name = :"#{@association.reflection.name}_count"
8
8
  owner = @association.owner
9
9
 
10
- if owner.class.has_reflection?(counter_name)
11
- owner.send(counter_name)
10
+ if owner.class.has_reflection?(counter_name) && owner.association(counter_name).loaded?
11
+ owner.association(counter_name).target
12
12
  else
13
13
  super(*args)
14
14
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Precount
3
- VERSION = "0.4.1"
3
+ VERSION = "0.4.2"
4
4
  end
5
5
  end
@@ -23,7 +23,7 @@
23
23
  <%= tweet.id %>
24
24
  </td>
25
25
  <td>
26
- <%= eager_load? ? tweet.replies_count : tweet.replies.count %>
26
+ <%= tweet.replies.count %>
27
27
  </td>
28
28
  <td>
29
29
  <%= tweet.in_reply_to.try(:id) %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-precount
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun