mongoid/mongoid — Issue #1648: cant use gte/lte etc on embedded docs..
Author: darkskiez
Created: 2012-01-26 22:30:31+00:00
State: open

#i suspect because strings / symbols dont work

class Foo
include Mongoid::Document
embeds_one :bar
field :a, type: Integer
end

class Bar
include Mongoid::Document
embedded_in :foo
field :b, type: Integer
end

f=Foo.new(:a=>10)
b=Bar.new(:b=>20)
f.bar=b
f.save

Foo.where(:"a.gt"=>5).count
# => 0 WHY?
Foo.where(:a.gt=>5).count
# => 1

Foo.where("a"=>10).count
=> 1
Foo.where(:a=>10).count
=> 1

Foo.where(:bar.b.gt=>5).count
# NoMethodError: undefined method `b' for :bar:Symbol
Foo.where(:"bar.b.gt"=>5).count
=> 0