0

我在查找所有无效节点时遇到问题。这是课程:

class MyNode
  include Neo4j::ActiveNode
  property :name
  property :is_valid, type: Integer, default: 0
end

创建我的节点时,该属性显然不会自动设置。然后我想搜索所有无效的节点,它返回 0

classobject.as(:n).where(is_valid: [0,'']).count

我也试过了

validates :is_valid, numericality: { only_integer: true }

我该如何处理?

4

1 回答 1

0

我通过系统地将 is_valid: 0 添加到创建它的参数中来解决了我的问题。我在想,因为它已被设置为默认值:0 它会自动设置

于 2015-02-13T11:42:08.663 回答