【发布时间】:2011-09-12 14:34:42
【问题描述】:
我有这个结构
class House
include Mongoid::Document
embeds_many :inhabitants
end
class Inhabitant
include Mongoid::Document
embedded_in :house
field :name
field :gender
field :age
end
我可以得到所有女性居住的房子:
houses = House.where("inhabitants.gender" => "female")
但是我怎样才能得到所有 50 岁以下女性居住的房子呢?如何为嵌入对象指定多个条件?
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 mongodb mongoid