by ydnaclementine · 3y ago · 0 comments
```
Post.includes(comments: :votes)
```
Similar stackoverflow: https://stackoverflow.com/a/24397716
If you can count in the database itself it's a big win. Although no doubt your solution is cleaner code.
[1] https://bhserna.com/tools-to-help-you-detect-n-1-queries.htm...