Open anshizzle opened 6 years ago
The documentation indicates that an array should be valid input for the rel_class
I assume you're referring to the comments in the source code? I had never noticed reference to this before myself. The documentation is incorrect. rel_class
does not accept an array. Maybe it did at one point in time, but it does not currently. There are multiple places in the Association
definition where rel_class
is assumed to not be an array, I see no support for handling an array, and there are no tests for an array input.
The method validating the rel_class
option should be updated to throw an error if passed an array, and that source code comment should be removed.
You may be able to pass in an either/or relation type string for the relation type argument of an association.
I.e. you might be able to get away with
has_many :out, :classes, type: ":STUDENT_OF|:MEMBER_OF", unique: true, model_class: [:Class, :Extracurricular]
I'll also note that the unique option (which corresponds to CREATE UNIQUE
) is deprecated in Neo4j.
It's also indicated in the error message:
ArgumentError: rel_class option must by String, Symbol, false, nil, or an Array of Symbols/Strings
and in this documentation page:
https://www.rubydoc.info/gems/neo4j/Neo4j/ActiveNode/HasN/ClassMethods#has_many-instance_method
But I agree re: seeing no tests/no handling in the source code about being able to accept an Array.
Going to see now if I get away with the relation type string.
As explained above, I'm getting the following NameError when calling a has_many relationship
Additional information which could be helpful if relevant to your issue:
Code example (inline, gist, or repo)
I have a class with the following has_many relationships:
and am adding the below:
has_many :out, :activities, rel_class: [:StudentOf, :MemberOf], unique: true
The documentation indicates that an array should be valid input for the rel_class, so I'm wondering if this is a Neo4j bug or if I'm not declaring the option correctly.
Has anyone run into this before? I'm currently working around it by writing a Cypher query to pull the relationship.
Here is the entire backtrace:
Runtime information:
Neo4j database version: 3.3.4
neo4j
gem version: 9.2.4neo4j-core
gem version: 8.1.4