Skip to content

Declared Relationships

Andreas Ronge edited this page Jul 21, 2014 · 8 revisions

has_many

A has_many declaration is used to generate accessor methods for traversing relationships as well as creating new relationships.

The first argument of the has_many is the name of the method that will be generated.

Example:

class Person
  include Neo4j::ActiveNode
  has_many :friends
end

This will generate a friends method on the Person class so that we can create new relationships between two nodes like this:

p = Person.create
p.friends << Person.create
Clone this wiki locally