【问题标题】:Rails Neo4j Migration Argument ErrorRails Neo4j 迁移参数错误
【发布时间】:2018-08-01 18:27:30
【问题描述】:

所以我有这两个类

class Tweet 
  include Neo4j::ActiveNode
  property :content, type: String

  property :created_at, type: DateTime
  property :updated_at, type: DateTime
  has_one(:user, :tweeted).from(:User)
end

class User 
  include Neo4j::ActiveNode
  property :username, type: String
  property :name, type: String
  property :email, type: String, default: ''
  validates :email, :username, uniqueness: true
  property :encrypted_password
  has_many(:Tweet, :tweeted)
end

每次我运行 rails neo4j:migrate 都会出现这样的错误

ArgumentError: 'type' 选项必须指定(即使是nil)或origin/rel_class 必须指定(Class#tweeted)

neo4jrb中如何正确创建节点之间的关系?

【问题讨论】:

    标签: ruby-on-rails neo4j


    【解决方案1】:

    正如错误消息所述,您没有明确定义tweeted 关系的类型。查看official documentation 了解更多详情。但是,以下应该有效:

    class Tweet 
      include Neo4j::ActiveNode
      property :content, type: String
      property :created_at, type: DateTime
      property :updated_at, type: DateTime
      has_one :out, :author, type: :author, model_class: :User
    end
    
    class User 
      include Neo4j::ActiveNode
      property :username, type: String
      property :name, type: String
      property :email, type: String, default: ''
      validates :email, :username, uniqueness: true
      property :encrypted_password
      has_many :in, :tweets, origin: :author
    end
    

    【讨论】:

      猜你喜欢
      • 2016-02-22
      • 2019-12-03
      • 2016-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-28
      • 2015-04-04
      • 2012-09-02
      相关资源
      最近更新 更多