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

<%= 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.

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)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs