title: Mongoid date range query
body: <p>I can't seem to find anything to make a date range query using Mongoid/Rails. Below are some queries I've tried (among about 100 others). If it returns anything, it always ignores the 'end_date'. Both dates are datetimes...</p>
  
  <pre><code>all(:conditions =&gt; {:created_at =&gt; start_date.to_datetime..end_date.to_datetime})
  </code></pre>
  
  <p>results in:</p>
  
  <pre><code>NoMethodError: undefined method `to_i' for Tue, 26 Apr 2011 00:00:00 +0000..Fri, 06 May 2011 00:00:00 +0000:Range
  </code></pre>
  
  <p>another example...</p>
  
  <pre><code>where(:created_at =&gt; {'$gte' =&gt; start_date,'$lt' =&gt; end_date})
  </code></pre>
  
  <p>results in a successful query but the end date is ignored. The results come back correctly after the start date but are not limited by the end date.</p>
  
  <p>I've been working on this problem for several days to no avail. Not much help online, in the forums or IRC.</p>
  
  <p>Would love to figure what I'm doing wrong :)</p>