{"action":"closed","issue":{"url":"https://api.github.com/repos/neo4jrb/neo4j/issues/1175","repository_url":"https://api.github.com/repos/neo4jrb/neo4j","labels_url":"https://api.github.com/repos/neo4jrb/neo4j/issues/1175/labels{/name}","comments_url":"https://api.github.com/repos/neo4jrb/neo4j/issues/1175/comments","events_url":"https://api.github.com/repos/neo4jrb/neo4j/issues/1175/events","html_url":"https://github.com/neo4jrb/neo4j/issues/1175","id":144263611,"number":1175,"title":"Objects inconsistently respond to .empty, .nil, etc","user":{"login":"Joshfindit","id":1937155,"avatar_url":"https://avatars.githubusercontent.com/u/1937155?v=3","gravatar_id":"","url":"https://api.github.com/users/Joshfindit","html_url":"https://github.com/Joshfindit","followers_url":"https://api.github.com/users/Joshfindit/followers","following_url":"https://api.github.com/users/Joshfindit/following{/other_user}","gists_url":"https://api.github.com/users/Joshfindit/gists{/gist_id}","starred_url":"https://api.github.com/users/Joshfindit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Joshfindit/subscriptions","organizations_url":"https://api.github.com/users/Joshfindit/orgs","repos_url":"https://api.github.com/users/Joshfindit/repos","events_url":"https://api.github.com/users/Joshfindit/events{/privacy}","received_events_url":"https://api.github.com/users/Joshfindit/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-29T13:23:30Z","updated_at":"2016-04-08T22:31:53Z","closed_at":"2016-04-08T22:31:53Z","body":"This relates to trying to find a performant way to display related nodes in a Rails view (more discussion here: https://github.com/neo4jrb/neo4j/issues/1172 ).\r\n\r\nWhile fumbling around at finding a solution by checking if there is a connected node, then displaying the correct information if there is (and showing 'none' when there is not), I've been using what seem to be the right choices:\r\n\r\n* `node.relationship.try?`\r\n* `node.relationship.results?`\r\n* `node.relationship.empty?`\r\n* `node.relationship.nil?`\r\n* `node.relationship?`\r\n\r\nUnfortunately, no single solution seems to work. `empty` is not always defined, `nil` will sometimes return false when where is no node, and so-on.\r\n\r\n\r\nThere are two parts to this question:\r\n\r\n1. Is there a better way to display the right content when an node is connected to other nodes?\r\n  - Both in a `has_one` and `has_many` situation\r\n2. Is there a method that is consistent across all relationship and node types that *always* returns (in the same format) whether there is a connected node or not?\r\n\r\n\r\n\r\n### Runtime information:\r\n\r\nNeo4j database version: 2.3.2\r\n`neo4j` gem version: 7.1.0\r\n`neo4j-core` gem version: 6.1.2"}}