我对 mongoid 有一些问题:
test "Test candidate" do
User.create(:id => 1, :sex => User::Male, :country => 1, :city => 1)
User.create(:id => 2, :sex => User::Female, :country => 1, :city => 1)
User.create(:id => 3, :sex => User::Female, :country => 1, :city => 1)
user = User.not_in(:id => [2]).second
assert_not_equal(user.id, 2)
end
测试失败。我尝试使用 where(:id => {'$nid' => [2]}),但效果相同。
怎么了?如何在 mongoid 中使用“不在”状态?
PS,“第二个”没问题,“第一个”测试通过,因为 id=1