Recently I upgraded to Neo4j 3.1.3, Neo4j.rb 8.0.13, and Neo4j-core 7.1.2. Since then, rels method throws undefined method 'rels' for #<Neo4j::Core::Node:xxxxxxxx>
error.
My query is,
student.rels(dir: :outgoing, type: :enrolled_in).count
Along with rels
method, create_rel
method is not working as well. I've been reading the docs to see if these two methods have been deprecated from newer versions, but no luck so far.
You might want to read the upgrade guide before reading the rest of this answer.
The rels
relationship was not added to the Neo4j::Core::Node
objects which replaced the old Node
objects in the old API. I believe we also had a rels
method in ActiveNode
.
If you are using ActiveNode
, the replacement is to define an association. Something like:
class Student
include Neo4j::ActiveNode
has_many :out, :all_nodes, type: :enrolled_in, model_class: false
end
# Then you can do:
student.all_nodes.count
However the fact that you're only following the enrolled_in
relationship makes me think that this might be going to specific nodes (maybe Course
?). If so I'd suggest doing:
class Course
include Neo4j::ActiveNode
end
class
include Neo4j::ActiveNode
has_many :out, :courses, type: :enrolled_in
# model_class of `Course` will be assumed based on the association's name
end
If you aren't using ActiveNode
but rather the neo4j-core
gem directly, you should use a Cypher query