Checking Join data for nil before accessing


#1

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?


#2

Justin K. 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.
To check, use property.pdf.nil? rather than property.pdf == nil. I
presume the latter doesn’t work because the NoRecordException is raised
before the comparison can be made.


#3

Alex Y. wrote:

Justin K. 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.
To check, use property.pdf.nil? rather than property.pdf == nil. I
presume the latter doesn’t work because the NoRecordException is raised
before the comparison can be made.

Thanks