this s more of a syntax question then a problem persay. I was optimizing
some older code on one of my projects when I hit and interesting
problem. First the Working Code:
placeholder = 0
while(@record_album[placeholder])
temp [email protected]_album[placeholder]
if(temp.parentid == Parent.id)
album_tree +="\t
href="#">#{@record[placeholder][“name”]}
placeholder+=1
end
end
Now Non working Code:
placeholder = 0
while(@record_album[placeholder].parentid == Parent.id)
album_tree +="\t
href="#">#{@record_album[placeholder][“name”]}
placeholder+=1
end
The non working code gives me a “You have a nil object when you didn’t
expect it! The error occurred while evaluating nil.parentid” exception.
I am hoping this is something stupid on my part, but if it isn’t then
why does the error occur
Darushin