We're using a jRuby on Rails with Neo4j, and we're getting some very odd errors. Currently, we have users able to create posts. Very rarely, it seems that they get unwrapped nodes in their "posts" relationships instead of Post objects. For example, in console, I iterated over one user's posts, and this is what it came up:
> user.posts.each{ |post| puts post }
#<Post:0x49ca112d>
#<Post:0xc9ddbea>
#<Post:0x7e706c75>
Node[438144]
#<Post:0x769dba83>
This is causing all sorts of problems, as we get errors like this whenever we try to access a property or relationship of one of these non-post posts:
undefined method `[any property or relationship]' for #<Java::OrgNeo4jKernelImplCore::NodeProxy:0x461784b6>
These naked nodes seem to be getting added to people's "post" relationships intermittently, and I can manually delete the node, but this seems to be only a stop-gap measure at best because they keep being created.
So, my question is, how do I (1) prevent these non-Post objects from being created in the first place, and how do I (2) purge my database of these objects?