title: Rails 3 query in multiple date ranges
body: <p>Suppose we have some date ranges, for example:</p>
  
  <pre><code>ranges = [
            [(12.months.ago)..(8.months.ago)],
            [(7.months.ago)..(6.months.ago)],
            [(5.months.ago)..(4.months.ago)],
            [(3.months.ago)..(2.months.ago)],
            [(1.month.ago)..(15.days.ago)]
           ]
  </code></pre>
  
  <p>and a <code>Post</code> model with <code>:created_at</code> attribute.</p>
  
  <p>I want to find posts where <code>created_at</code> value is in this range, so the goal is to create a query like:</p>
  
  <pre><code>SELECT * FROM posts WHERE created_at 
      BETWEEN '2011-04-06' AND '2011-08-06' OR
      BETWEEN '2011-09-06' AND '2011-10-06' OR
      BETWEEN '2011-11-06' AND '2011-12-06' OR
      BETWEEN '2012-01-06' AND '2012-02-06' OR
      BETWEEN '2012-02-06' AND '2012-03-23';
  </code></pre>
  
  <p>If you have only one range like this:</p>
  
  <pre><code>range = (12.months.ago)..(8.months.ago)
  </code></pre>
  
  <p>we can do this query:</p>
  
  <pre><code>Post.where(:created_at =&gt; range)
  </code></pre>
  
  <p>and query should be:</p>
  
  <pre><code>SELECT * FROM posts WHERE created_at 
      BETWEEN '2011-04-06' AND '2011-08-06';
  </code></pre>
  
  <p>Is there a way to make this query using a notation like this <code>Post.where(:created_at =&gt; range)</code>?</p>
  
  <p>And what is the <em>correct</em> way to build this query?</p>
  
  <p>Thank you</p>