Ruby 在Mongomapper作用域中不相等(ne)和/或未返回正确的结果

Ruby 在Mongomapper作用域中不相等(ne)和/或未返回正确的结果,ruby,mongodb,model,scope,mongomapper,Ruby,Mongodb,Model,Scope,Mongomapper,我无法在Mongomapper中使用OR将这两个作用域链接在一起: scope :comment_is_nil, where(:comment => nil) scope :post_not_blank, where(:post.ne => "") 它应该返回注释不是nil或post不是空的模型对象 这不起作用: Model.where("$or" => [{:comment_is_nil, :post_not_blank]) 有什么想法吗?链接作用域是一个和操作,因此M.

我无法在Mongomapper中使用OR将这两个作用域链接在一起:

scope :comment_is_nil, where(:comment => nil)
scope :post_not_blank, where(:post.ne => "")
它应该返回注释不是nil或post不是空的模型对象

这不起作用:

Model.where("$or" => [{:comment_is_nil, :post_not_blank])

有什么想法吗?

链接作用域是一个操作,因此
M.comment\u为零。post\u not\u blank
将无法正常工作。看起来像这样:

Model.where(
    :$or => [
        { :comment => nil },
        { :post.ne => ''  }
    ]
)
因此,您需要通过手动扩展作用域来为它提供一组单独的条件