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...
all(:conditions => {:created_at => start_date.to_datetime..end_date.to_datetime})
results in:
NoMethodError: undefined method `to_i' for Tue, 26 Apr 2011 00:00:00 +0000..Fri, 06 May 2011 00:00:00 +0000:Range
another example...
where(:created_at => {'$gte' => start_date,'$lt' => end_date})
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.
I've been working on this problem for several days to no avail. Not much help online, in the forums or IRC.
Would love to figure what I'm doing wrong :)
There was a bug in Mongoid. Fixed now.
For more information: