mongoid TypeError:键必须是字符串或符号

时间:2013-03-29 14:24:11

标签: ruby mongodb mongoid

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

1 个答案:

答案 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')}}})