所以我有这两个班
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中正确创建节点之间的关系?
答案 0 :(得分:1)
如错误消息所述,您没有明确定义tweeted
关系的类型。查看django-categories了解更多详细信息。但是,以下方法应该起作用:
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