Hi there,
I have a little trouble figuring out this error:
undefined method `parent'' for []:Array
#{RAILS_ROOT}/app/controllers/forums_controller.rb:42:in `new''
This is my def new in my controller
def new
@menu_current = "forum"
@page_title = "Kampp Productions - Forum - Opret ny"
@forum = Forum.new
@parent = params[:parent]
if @parent
@parentForum = Forum.find_by_sql("select * from forums where
parent = ''"+@parent.to_s+"''")
@topForum = Forum.find_by_sql("select * from forums where parent
''"+@parentForum.parent.to_s+"'' limit 1")
end
end
Does anyone have any idear whats wrong ?
- Emil
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Hi Emil, my guess is, that your @parentForum class-var is populated as an array by the find_by_sql method. This array doesn't know how to work with the message @parentForum.parent.to_s give @parentForum[0].parent.to_s a try. Cheers, Jan -- http://www.inviado.de - Internetseiten fr RAe http://www.xing.com/profile/Jan_Prill --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---