当我在Rails控制台中运行此查询时:
1.9.3p286 :118 > cs = Conference.any_of({:schedule_cache => { :$elemMatch => { :start_date.gte => Date.parse('7 Mar 2013'), :end_date.lte => Date.parse('8 Mar 2013')}}})
1.9.3p286 :118 > cs.count
我明白了:
TypeError: keys must be strings or symbols
答案 0 :(得分:1)
您是否尝试过使用字符串键?
cs = Conference.any_of({'schedule_cache' => { '$elemMatch' => { 'start_date.gte' => Date.parse('7 Mar 2013'), 'end_date.lte' => Date.parse('8 Mar 2013')}}})