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:
http://wiki.rubyonrails.org/rails/pages/SingleTableInheritance
"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
them."
Short of adding a file for each child model in the inheritance tree,
does anyone have a work around for this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---