title: 'Splitting' ActiveRecord collection
body: <p>Let's say I have two models Post and Category:</p>
  
  <pre><code>class Post &lt; ActiveRecord::Base
    belongs_to :category
  end
  
  class Category &lt; ActiveRecord::Base
    has_many :posts
  end
  </code></pre>
  
  <p>Is there a method that will allow me to do something like</p>
  
  <pre><code>posts = Post.find(:all)
  
  p = Array.new
  
  p[1] = posts.with_category_id(1)
  p[2] = posts.with_category_id(2)
  p[3] = posts.with_category_id(3)
  ...
  
  or
  
  p = posts.split_by_category_ids(1,2,3)
  
  =&gt; [posts_with_category_id_1, 
      posts_with_category_id_2,
      posts_with_category_id_3]
  </code></pre>
  
  <p>In other words, 'split' the collection of all posts into arrays by selected category ids</p>