RelInvalidError - from_node and to_node must be node objects

36 views
Skip to first unread message

John Clegg

unread,
Nov 11, 2014, 3:38:01 AM11/11/14
to neo...@googlegroups.com
Hi 

I'm getting "RelInvalidError - from_node and to_node must be node objects" when I'm trying to create a relationship. 


      foo = Dish.where("result.foo_id = #{foo_id}")

      bah = Patron.where("result.bah_id = #{bah_id}")

      rel = Rating.create(from_node: foo, to_node: bah, value: 1)

This give me an "RelInvalidError - from_node and to_node must be node objects" . I saw the error in the issues list but it looks like it has been fixed .

Using neo4j-core 3.0.3

Using neo4j 3.0.2

What am I doing wrong ?

John

Chris Grigg

unread,
Nov 11, 2014, 12:15:35 PM11/11/14
to neo...@googlegroups.com
If you're doing exactly what you demonstrated, call `first` on both of those variables -- they return enumerables. Alternatively, use `find_by`.
--
You received this message because you are subscribed to the Google Groups "neo4jrb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4jrb+u...@googlegroups.com.
To post to this group, send email to neo...@googlegroups.com.
Visit this group at http://groups.google.com/group/neo4jrb.
For more options, visit https://groups.google.com/d/optout.

John Clegg

unread,
Nov 11, 2014, 10:16:55 PM11/11/14
to neo...@googlegroups.com
Thanks.

I've changed the code to use find_by and now I get a different error

 `_rel_creation_query': undefined method `r' for nil:NilClass (NoMethodError)

I've tested the find_by and create relationship logic with the "Movie" demo data and it doesn't error. I need investigate more what is happen with my model / code . 

JC


On Wednesday, November 12, 2014 6:15:35 AM UTC+13, Chris Grigg wrote:
If you're doing exactly what you demonstrated, call `first` on both of those variables -- they return enumerables. Alternatively, use `find_by`.

On Tuesday, November 11, 2014, John Clegg <jo...@projectx.co.nz> wrote:
Hi 

I'm getting "RelInvalidError - from_node and to_node must be node objects" when I'm trying to create a relationship. 


      foo = Dish.where("result.foo_id = #{foo_id}")

      bah = Patron.where("result.bah_id = #{bah_id}")

      rel = Rating.create(from_node: foo, to_node: bah, value: 1)

This give me an "RelInvalidError - from_node and to_node must be node objects" . I saw the error in the issues list but it looks like it has been fixed .

Using neo4j-core 3.0.3

Using neo4j 3.0.2

What am I doing wrong ?

John

--
You received this message because you are subscribed to the Google Groups "neo4jrb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4jrb+unsubscribe@googlegroups.com.

Chris Grigg

unread,
Nov 11, 2014, 11:26:06 PM11/11/14
to neo...@googlegroups.com
Good luck! Let us know if there's anything you want another set of eyes on.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4jrb+u...@googlegroups.com.

John Clegg

unread,
Nov 13, 2014, 2:48:40 AM11/13/14
to neo...@googlegroups.com
I managed to find out why I was having a problem. I had two problems:

1) I used "id" as id_property which had a conflict when creating a relationship

2) I hadn't created UUID's for my nodes. Which meant that when the create function was looking for neo_id it failed.

Now create is working like a charm !

Thanks to Chris for the extra help.

John
Reply all
Reply to author
Forward
0 new messages