railsirrigation
2008-Feb-01 18:21 UTC
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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
railsirrigation
2008-Feb-01 20:26 UTC
Re: Stumped on silly nil object but debug shows it is not nil
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) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---