What is this error?

Hi there,

I have a little trouble figuring out this error:

undefined method parent' for []:Array #{RAILS_ROOT}/app/controllers/forums_controller.rb:42:innew’

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 = ‘“[email protected]_s+”’”)
@topForum = Forum.find_by_sql(“select * from forums where parent =
‘“[email protected]_s+”’ limit 1”)
end
end

Does anyone have any idear whats wrong ?

  • Emil

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 für RAe
Jan Prill - Teamleiter - adesso SE | XING