I think that $gt
is being interpreted as a reference to global variable $gt
, not a symbol :$gt
. And since you can't use colonized hash syntax with variables, it rightfully expects a hashrocket. The query should work with both string and symbol:
y = x.find({'b' => {'$gt' => 0}})
y = x.find({'b' => {:$gt => 0}})