We actually have an example of something similar in our new intro screencast:
https://www.youtube.com/watch?v=bDjbqRL9HcM&list=UUIURLB8eZjFU8AH-GKeQI6g
It would work for you assuming that you want to have a specific list
of genders. The basic idea is that you would create a drop-down in
your form which lists all of the nodes and their IDs, you would pass
that ID from the form to the controller as "gender" property, and then
ActiveNode would find the node with that ID and make a relationship.
Example code:
person.update(first_name: 'Brian', gender: <ID string representing the
gender node>)
Or alternatively I think you could do:
person.gender = <ID string representing the gender node>
person.save
If you want to allow for free-form text entry (I saw a great
presentation on why you might do this. Can't seem to find it now):
gender = Gender.query_as(:gender).merge(gender: {name: 'Whatever
String'}).pluck(:gender).first
person.update(first_name: 'Brian', gender: gender)
I think that will work. I'm also realizing it's not ideal and we
should probably have some find_or_create type higher level
functionality (here I'm using query_as to get to the Cypher generation
API in neo4j-core).
Brian
;p
> --
> 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.