amatsuda/kaminari — pull request #431 by codeodor (2013-08-11 21:09:29+00:00)
Title: Count rows returned by the query instead of keys in #count hash

I added a test case and code to fix the issue we discussed in #373.

Essentially:

When you use `group` on a relation, its `count` returns a hash of results. Sometimes (as in the demonstrated test case), the number of keys in that hash is not the correct count of the number of rows, as kaminari was previously assuming.

This patch fixes that by taking the original query and counting it's rows via a subquery, and avoids doing it using interpolation (as @zzak already mentioned would be unacceptable).