Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Neo4j模型类的不一致行为_Ruby On Rails_Neo4j_Neo4j.rb - Fatal编程技术网

Ruby on rails Neo4j模型类的不一致行为

Ruby on rails Neo4j模型类的不一致行为,ruby-on-rails,neo4j,neo4j.rb,Ruby On Rails,Neo4j,Neo4j.rb,在我的项目中,我使用ActiveNodemodel和neo4jgem创建了5个模型 有一个名为Disease的模型,定义为: class Disease include Neo4j::ActiveNode property :disease, type: String, constraint: :unique property :created_at, type: DateTime property :updated_at, type: DateTime

在我的项目中,我使用
ActiveNode
model和neo4jgem创建了5个模型

有一个名为Disease的模型,定义为:

  class Disease
    include Neo4j::ActiveNode
    property :disease, type: String, constraint: :unique
    property :created_at, type: DateTime
    property :updated_at, type: DateTime

    enum factor_effect: [:relief, :worsen]

    # Associations
    has_many :in, :factors, type: :AFFECTED_BY
  end
和因素:

  class Factor
    include Neo4j::ActiveNode
    property :factor, type: String, constraint: :unique
  end
我可以轻松地为Factor创建节点,但对于Disease,它会使用
create
函数出错,并使用
new
方法返回QueryProxy对象。(至于其他模型,它们的工作原理与预期相同)

以下是在控制台上运行的几个命令:

2.3.3 :012 >   f = Factor.new
=> #<Factor uuid: nil, factor: nil>
2.3.3 :013 > f.factor = "drinking more water"
=> "drinking more water"
2.3.3 :014 > f
=> #<Factor uuid: nil, factor: "drinking more water">
2.3.3 :015 > f.save
HTTP REQUEST: 49ms GET http://localhost:7474/db/data/schema/constraint (0 bytes)
HTTP REQUEST: 8ms GET http://localhost:7474/db/data/schema/index (0 bytes)
WARNING: The constraint option is no longer supported (Defined on Disease for disease)
WARNING: The constraint option is no longer supported (Defined on Factor for factor)
CYPHER CREATE (n:`Factor`) SET n = {props} RETURN n | {:props=>{:uuid=>"33f683d4-a6b2-4c7a-84f9-549088780033", :factor=>"drinking more water"}}
HTTP REQUEST: 682ms POST http://localhost:7474/db/data/transaction (1 bytes)
HTTP REQUEST: 385ms POST http://localhost:7474/db/data/transaction/5/commit (0 bytes)
WARNING: The constraint option is no longer supported (Defined on Disease for disease)
WARNING: The constraint option is no longer supported (Defined on Factor for factor)
=> true
2.3.3 :016 > f
=> #<Factor uuid: "33f683d4-a6b2-4c7a-84f9-549088780033", factor: "drinking more water">

这对我来说真的很糟糕,我没有任何解决办法。请帮忙

我真的不知道你为什么会因为
Disease.new
而得到
QueryProxy
。我已尝试在本地测试您的代码,我得到:

#<Disease uuid: nil, created_at: nil, disease: nil, factor_effect: nil, updated_at: nil>
#
也许你的代码中还有其他的东西影响着事情?您可以尝试删除代码,直到它开始工作(尽管这只是一个暗中操作)


之所以出现
警告
s,是因为属性上不再支持
constraint::unique
。该选项用于在加载模型时自动创建约束,但维护起来却成了一场噩梦。现在应该通过迁移创建约束。请参阅迁移指南,尤其是我真的不知道为什么您会收到
疾病的
查询程序。我已尝试在本地测试您的代码,我得到:

#<Disease uuid: nil, created_at: nil, disease: nil, factor_effect: nil, updated_at: nil>
#
也许你的代码中还有其他的东西影响着事情?您可以尝试删除代码,直到它开始工作(尽管这只是一个暗中操作)


之所以出现
警告
s,是因为属性上不再支持
constraint::unique
。该选项用于在加载模型时自动创建约束,但维护起来却成了一场噩梦。现在应该通过迁移创建约束。请参阅迁移指南,尤其是

是否有文档页面或博客帖子,您在其中找到了
constraint::unique
?我想删除所有对它的引用是的…我肯定在博客上看到过。我一看到这个链接就马上发布。@BrianUnderwood,在neo4j的短片系列中,在第2集(属性)中,你定义了这个
约束。非常好,谢谢!我将添加一个注释您是否在文档页面或博客帖子中找到了
constraint::unique
?我想删除所有对它的引用是的…我肯定在博客上看到过。我一看到这个链接就马上发布。@BrianUnderwood,在neo4j的短片系列中,在第2集(属性)中,你定义了这个
约束。非常好,谢谢!我将添加一个注释