# Checking Join data for nil

**URL:** <https://www.ruby-forum.com/t/checking-join-data-for-nil/52171>\
**Category:** Ruby\
**Created:** [January 11, 2006, 5:58pm UTC](https://www.ruby-forum.com/t/checking-join-data-for-nil/52171 "2006-01-11T17:58:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@jkay](https://www.ruby-forum.com/u/jkay)\
**Post date:** [January 11, 2006, 5:58pm UTC](https://www.ruby-forum.com/t/checking-join-data-for-nil/52171/1 "2006-01-11T17:58:48Z")

</div>

So I have a join 1:0…1. If there is nothing in the child side I get an  
error when I say property.pdf.name that I can’t access nil.name. But I  
can’t seem to figure out how to check if pdf is nil or not before I call  
the .name function. If I test for property.pdf == nil it always comes  
back as nil, which it isn’t.

Any ideas?

---

<div class="post-metadata">

**Author:** ![jkay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@jkay](https://www.ruby-forum.com/u/jkay)\
**Post date:** [January 11, 2006, 10:12pm UTC](https://www.ruby-forum.com/t/checking-join-data-for-nil/52171/2 "2006-01-11T22:12:40Z")

</div>

On 1/11/06, Justin K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> So I have a join 1:0…1. If there is nothing in the child side I get an  
> error when I say property.pdf.name that I can’t access nil.name. But I  
> can’t seem to figure out how to check if pdf is nil or not before I call  
> the .name function. If I test for property.pdf == nil it always comes  
> back as nil, which it isn’t.
> 
> Any ideas?

I’m not exactly sure what you are doing, but in general to check for  
nil you can just use “if” like so (nil is false):

if property.pdf  
puts property.pdf.name  
end

Or if you want to be explicit:

unless property.pdf.nil?  
puts property.pdf.name  
end

If property.pdf is always nil, then you have some other bug in your  
code.

Ryan
