Hi everyone, I'm trying to organize my sources, according to the new 1.2 specifications. So, i've an Animal class, with some subclasses (Dog,Bird,Snake). Animal is in /model, the others in /models/animals. When i've to instantiate a Dog, doing something like Animals::Dog.new i've an exception: The single-table inheritance mechanism failed to locate the subclass: 'Dog'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. (cut) This occurs why Rails is going to write just "Dog" in the type column, and not "Animals::Dog", so in the next call to the object the operation fails. I'm doing something messy or it's just an issue? Thanks, alessio.
on 2007-02-14 12:44
on 2007-02-14 14:01
I looked in trac to see if there was a ticket for this and I couldn't find one, although that doesn't necessarily mean one doesn't exist. If I were you, I would check out trac more thoroughly and if you can't find anything related to it, open a ticket. be sure to include a test. My guess is that demodulize is getting called on the class name when it shouldn't be. Also, if you were to replace the type from 'Dog' to 'Animals::Dog' in the database, it loads the record just fine. in the meantime, i would just put all your animal models in your main app/models directory, and change the class definitions from class Animals::Dog < Animal end to class Dog end