diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c57f7a..7e18d62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### 8.0.0 - Drop support to EOL ruby and rails +- Reference ancestor_hierarchies in depth instead of ancestors to avoid n+1 ## [7.4.0](https://github.com/ClosureTree/closure_tree/tree/7.4.0) diff --git a/lib/closure_tree/model.rb b/lib/closure_tree/model.rb index d55658c..cc64ae4 100644 --- a/lib/closure_tree/model.rb +++ b/lib/closure_tree/model.rb @@ -77,7 +77,7 @@ def leaves end def depth - ancestors.size + ancestor_hierarchies.size end alias_method :level, :depth