Hi, my app is using single table inheritance and has run into the
“uninitialized constant” error once I remove the model call.
I set up my STI using the instructions in the wiki, which I am
guessing are badly out of date now:
"If you have an “uninitialized constant” error:
Note: Rails must ‘see’ the file containing the STI classes before it
can use them, otherwise you’ll end up with an “uninitialized constant”
error. This can be a problem if the name of the class and the name of
the file defining it are not the same, e.g. you have the model
‘Manager’ in the file ‘employees.rb’. Rails will not be able to divine
the filename from the class name in this case.
An easy way to do fix this is to add “model :employees” to your
application.rb controller, where ‘employees’ is the name of the file
containing the STI class minus the extension (so in this case, the
model would be contained in a file named ‘employees.rb’.) This forces
Rails to load that file and ‘see’ all the models you have defined in
it, and it will then know of your STI classes when you go to use
Short of adding a file for each child model in the inheritance tree,
does anyone have a work around for this?