Forum: Ruby on Rails What is this error ?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
525e0c75f4f5c1d0ab0b6cc91575b74f?d=identicon&s=25 Emil Kampp (emuen)
on 2007-01-16 08:17
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 =
    @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")

Does anyone have any idear whats wrong ?

 - Emil
E48d29dc8fedb2878fa518d41cc63d88?d=identicon&s=25 Jan Prill (Guest)
on 2007-01-16 08:45
(Received via mailing list)
Hi Emil,

my guess is, that your @parentForum class-var is populated as an array
the find_by_sql method. This array doesn't know how to work with the
@parentForum.parent.to_s give @parentForum[0].parent.to_s a try.


–––––––––––––––––––––––––––––– - Internetseiten für RAe
This topic is locked and can not be replied to.