# Stumped on silly nil object but debug shows it is not nil

**URL:** <https://www.ruby-forum.com/t/stumped-on-silly-nil-object-but-debug-shows-it-is-not-nil/127840>\
**Category:** Rails\
**Created:** [February 1, 2008, 7:22pm UTC](https://www.ruby-forum.com/t/stumped-on-silly-nil-object-but-debug-shows-it-is-not-nil/127840 "2008-02-01T19:22:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![railsirrigation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/edb3f5/32.png) [@railsirrigation](https://www.ruby-forum.com/u/railsirrigation)\
**Post date:** [February 1, 2008, 7:22pm UTC](https://www.ruby-forum.com/t/stumped-on-silly-nil-object-but-debug-shows-it-is-not-nil/127840/1 "2008-02-01T19:22:34Z")

</div>

\<%= faq.faqcats[:title] -%\> in view kills it with this error:

“You have a nil object when you didn’t expect it!  
You might have expected an instance of ActiveRecord::Base.  
The error occurred while evaluating nil.[]”

Extracted source (around line #16)

16: \<%= faq.faqcats[:title] -%\>

===scenario===

I am using :include =\> [:faqcats, :modes], in my controller find  
request

in my view: \<%= debug(faq) -%\> prints

================  
— !ruby/object:Faq  
attributes:  
answer: I hope someone has an answer so I can move-on  
weight: “0”  
faqcat\_id: “2”  
markdown: “1”  
mode\_id: “4”  
id: “13”  
question: Why can’t I grab Faqcat title  
created: 2007-11-20 10:19:00  
updated: 2007-11-20 10:19:00  
attributes\_cache: {}

faqcats: !ruby/object:Faqcat  
attributes:  
title: Trouble Shooting  
weight: “0”  
mode\_id: “0”  
id: “2”  
parent\_id: “0”  
attributes\_cache: {}

# modes: !ruby/object:Mode attributes: title: “on” id: “4” attributes\_cache: {}

\<%= faq.modes[:title] -%\> prints “on” as expected  
\<%= faq.faqcats[:title] -%\> kills it

The only thing diffrent about the class Faqcat \< ActiveRecord::Base  
is that it is ‘acts\_as\_tree’

Any help would be great.

---

<div class="post-metadata">

**Author:** ![railsirrigation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/edb3f5/32.png) [@railsirrigation](https://www.ruby-forum.com/u/railsirrigation)\
**Post date:** [February 1, 2008, 9:27pm UTC](https://www.ruby-forum.com/t/stumped-on-silly-nil-object-but-debug-shows-it-is-not-nil/127840/2 "2008-02-01T21:27:01Z")

</div>

Like I said silly. I ended up having a Faqs with the faqcat\_id of  
Faqcats that had been removed.  
so some nil objects. duhhh… (I knew I forgot to finish something  
in the admin the other day)
