This project is archived and is in readonly mode.

#6504 new
Joseph Palermo

Make associations respect store_full_sti_class

Reported by Joseph Palermo | March 2nd, 2011 @ 09:41 AM

Currently when doing an association preload, it will respect store_full_sti_class and use sti_name for the class it is loading.

However, all of the association code that actually sets the value of these columns uses base_class.name rather than sti_name.

This means association preloading won't work on polymorphic associations if you have store_full_sti_class disabled.

This patch creates a polymorphic_name class method that just calls base_class.sti_name and then uses that in both the association preload code, as well as when the _type column gets set in the association code.

Test is included.

Comments and changes to this ticket

  • Joseph Palermo

    Joseph Palermo March 11th, 2011 @ 04:42 PM

    Looking closer, I see a lot of calls to "constantize" in the associations, rather than looking up the sti_class_name. Is store_full_sti_class supposed to apply to polymorphic type columns, or just to sti type columns?

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