What’s the proper way to create a relation from an instance of a Neo4j class to another instance of that class?
For example, if I am modeling courses in a course catalog with a model for courses that are prereqs for other courses.
I am using neo4j with rails:
Model:
class Course < Neo4j::Rails::Model property :name
has_n(:prereqs).from(Course, :leadstos) has_n(:leadstos)
Creating objects and relation:
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'
However, arithmetic.leadstos.each {|node| puts node[:name]} comes out as blank.
You will have to declare :leadtos relation as