Acts_as_tree, polymorphism and class loading problems


#1

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:indata’
#{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