【发布时间】:2012-01-03 17:24:44
【问题描述】:
创建从 Neo4j 类的实例到该类的另一个实例的关系的正确方法是什么?
例如,如果我在课程目录中为课程建模,其中的课程模型是其他课程的先决条件。
我正在使用带有 rails 的 neo4j:
型号:
类课程 has_n(:prereqs).from(Course, :leadstos) has_n(:leadstos)
创建对象和关系:
algebra = Course.create :name => 'algebra'
arithmetic = Course.create :name => 'arithmetic'
algebra.prereqs << arithmetic
algebra.save!
arithmetic.save!
algebra.prereqs.each {|node| puts node [:name]}
#prints 'arithmetic'
但是,arithmetic.leadstos.each {|node| puts node[:name]} 显示为空白。
【问题讨论】:
标签: ruby-on-rails neo4j