Barak Peleg
1 min readJun 22, 2017

--

Hi Eric,

Very interesting read. I totally agree that for many cases the SQL alternatives benefits outweigh the performance cost.

I’m trying to use this solution wih cancancan and I’m stumbling with issues that the counts aren’t loaded in the object returned by the query.

E.g.

@author = Author.with_counts.find_by id: params[:id]
@author.books_count

raises a NoMethodError (undefined method books_count’…

Do you have any experience with this?

--

--