【问题标题】:Getting Started with Neo4j and Ruby - Error: Neo4j::DeprecatedSchemaDefinitionError in Books#index - id_property is the root of the issueNeo4j 和 Ruby 入门 - 错误:Books#index 中的 Neo4j::DeprecatedSchemaDefinitionError - id_property 是问题的根源
【发布时间】:2019-02-18 20:52:39
【问题描述】:

Neo4j 和 Ruby 入门

https://neo4j.com/developer/ruby-course/

我遵循了这个指示。

rails new asset_portal -m http://neo4jrb.io/neo4j/neo4j.rb -O
cd asset_portal
rake neo4j:install[community-latest]
rake neo4j:start

我完成了项目设置并启动了 neo4j 服务器。

然后我按照说明为用户、资产、类别和书籍创建脚手架。

然后我把书的模型改成了

按照指示。

我也按照指示进行了更改。

现在我运行迁移,并启动服务器。

rake neo4j:migrate
rails s
open http://localhost:3000/books

我收到迁移错误

Neo4j::DeprecatedSchemaDefinitionError in Books#index
Some schema elements were defined by the model (which is no longer supported), but they do not exist in the database.  Run the following to create them if you haven't already:

rake neo4j:generate_schema_migration[constraint,Book,isbn]


And then run `rake neo4j:migrate`

我按照说明运行了

rake neo4j:generate_schema_migration[constraint,Book,isbn]
rake neo4j:migrate

我仍然遇到同样的错误。

我发现了一个涉及相同错误的 neo4j git 链接,https://github.com/neo4jrb/neo4j/issues/1356。它说“id_property”是问题的根源。但我无法从这个帖子中得到明确的答案。

我正在按照 Neo4j 手册中的说明将书籍模型更改为

id_property :isbn

其他人必须已经遇到这个错误并解决了这个问题。 (也许 Neo4j 手册现在已经过时了)。请帮忙。

我在 Mac 上运行它。在我开始这个项目之前,我刚刚在我的 Mac 上更新了 rake、ruby。

$ rails --version
Rails 5.2.2

$ ruby --version
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin17]

【问题讨论】:

    标签: ruby-on-rails neo4j


    【解决方案1】:

    我从手册中删除了这一行(手册已过时)

    id_property :isbn
    

    来自指令。

    相反,我使用

    rake neo4j:generate_schema_migration[constraint,Book,isbn]
    

    这会让

    - CONSTRAINT ON ( book:Book ) ASSERT book.isbn IS UNIQUE
    

    在我运行之前

    rake neo4j:migrate
    

    这应该可以解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-19
      • 1970-01-01
      相关资源
      最近更新 更多