Forum: Ruby on Rails acts_as_tree, polymorphism and class loading problems

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3a6666f57152610f172a77c8fe6a7420?d=identicon&s=25 marcus (Guest)
on 2005-12-27 21:39
(Received via mailing list)
I have a tree (acts_as_tree) with nodes where each node is instances of
different subclasses of Node. Each Node subclass knows how to point to
another table/instance in order to accomplish extension by composition.
This works good most of the time where I either loops over just the
nodes without accessing the "external" data (the instance pointed to by
Node subclass) or just accesses the external data straight away.

But I do get problems when I try to access the external data through the
nodes when traversing the tree? I get the following (in different areas
of the error screen):

Error description:
------------------
uninitialized constant SectionFolder
====================================
Trace:
-----
c:/marcus/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:200:in
`const_missing'
(eval):3:in `data'
#{RAILS_ROOT}/app/helpers/pages_helper.rb:33:in `map'
....
====================================
"Another" description:
----------------------
This error occured while loading the following files:
    section_folder.rb

SectionFolder in this case is a class that a Node subclass points to
(SectionFolderNode actually).

Any way around this apart from having to do a require for every possible
class in some controller (or in environment.rb)? Loop over the files in
/app/model and require them?

Regards,

/Marcus
This topic is locked and can not be replied to.