This project is archived and is in readonly mode.

#3034 new
tim_linquist

Rails Single Table Inheritance loading child classes

Reported by tim_linquist | August 11th, 2009 @ 03:31 AM

I am using Rails 2.1 & Ruby 1.8.7. I have an issue where querying an association proxy or the parent class of that association does not include the types of the child classes in the query. The cause appears to be that Rails internal loading engine does not properly load child models of models using Single Table Inheritance.

I resolved this temporarily by explicitly loading all of the classes in the env.rb file. So now when I call app.breadcrumbs it generates a select statement with a where clause: "WHERE type='Breadcrumb' OR type='Mark' OR type='Measure'".

I would be happy to dig through the Rails internals and provide a patch if someone can at least point me where to dig. I also looked for similar bugs but found none.

If this bug has already been resolved I apologize for the erroneous ticket.

I have attached a sample file that demonstrates my structure.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Pages