Skip to content

Commit 307ea52

Browse files
committed
Fix implementation of Mongoid::Tree::CounterCaching for Mongoid 7.x
1 parent f400efc commit 307ea52

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/mongoid/tree/counter_caching.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ module CounterCaching
1515
metadata = relations['parent']
1616
metadata.options[:counter_cache] = true
1717

18-
add_counter_cache_callbacks(metadata)
18+
if respond_to?(:add_counter_cache_callbacks)
19+
add_counter_cache_callbacks(metadata)
20+
else
21+
metadata.send(:define_counter_cache_callbacks!)
22+
end
1923
end
2024
end
2125
end

0 commit comments

Comments
 (0)