1

当我在 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
4

1 回答 1

1

您是否尝试过使用字符串键?

cs = Conference.any_of({'schedule_cache' => { '$elemMatch' => { 'start_date.gte' => Date.parse('7 Mar 2013'), 'end_date.lte' => Date.parse('8 Mar 2013')}}})
于 2013-03-29T14:55:48.343 回答