<h3 class="add-vertical-margins">
  <% if category.hits.count == 1 %>
    <%= category.hits.length %> <%= category.title.singularize %>
  <% elsif category.hits.length >= 2 and category.hits.length < 10 %>
    <%= category.hits.length %> <%= category.title %>
  <% else %>
    Top <%= category.hits.length %> <%= category.title %>
  <% end %>
</h3>

<h3 class="add-vertical-margins">
  <% if category.hits.length == 1 %>
    <%= category.hits.length %> <%= category.title.singularize %>
  <% elsif category.hits.length >= 2 and category.hits.length < 10 %>
    <%= category.hits.length %> <%= category.title %>
  <% else %>
    Top <%= category.hits.length %> <%= category.title %>
  <% end %>
</h3>

Stop ActiveRecord generating nonsense SQL with .count
Stop ActiveRecord generating nonsense SQL with .count

A bare count on a query which selects specific fields instead of * is turned into
invalid SQL by ActiveRecord. This is newly documented:

   https://github.com/rails/rails/commit/3023363fff502487740bd0b83a3069320551ec96

When we're selecting only some fields, .count generates COUNT(field1, field2)
which is invalid SQL. The recommended solution for this is to use .count(:all)
explicitly. In this case the rest of the partial uses .length, so I'm using
that instead here for consistency.

This fixes the last feature failure.
