title: In Rails, how to group by count of elements in array field?
body: <p>Given ActiveRecord Model <code>Foo</code> with a field <code>a_of_i</code> that is array of integers:</p>
  <pre><code># Foo:
  id, a_of_i
  101, [1,2,3,4]
  102, []
  103, [11, 12, 13, 14, 15, 16]
  104,  [1, 2, 52, 53]
  </code></pre>
  <p>Is there an ActiveRecord query that will group by the count of the #elements in an array column, eg produce:</p>
  <pre><code># Foo.some_query returns something like [[count, id], [count, id]...]
  =&gt; [ [6, 103], [4, 101], [4, 104], [0, 102] ]
  # or perhaps, if easier:
  =&gt; { 6 =&gt; [103], 4 =&gt; [101,104], 0 =&gt; [102] }
  </code></pre>