This project is archived and is in readonly mode.
Polymorphic Associations & STI don't record the correct model type
Reported by ronin-18882 (at lighthouseapp) | July 3rd, 2008 @ 08:35 PM | in 2.x
When using a polymorphic association on a model that uses STI, the correct model type is not recorded.
This has been identified before and is actually fixed with the patch here by removing instances of base_class:
http://dev.rubyonrails.org/attac...
Is there a reason that this cannot be applied?
Comments and changes to this ticket
-
Pratik July 4th, 2008 @ 12:18 AM
- State changed from new to incomplete
- Assigned user set to Pratik
The patch is missing tests.
Thanks.
-
Pratik August 3rd, 2008 @ 02:34 PM
- State changed from incomplete to wontfix
Closing till any progress is made.
-
Trek April 13th, 2010 @ 05:06 AM
This is an oldie, but I run across it as a problem from time to time. Patch with included test applies to 2.3.x for belongs_to assocations.
-
Conrad Taylor January 28th, 2011 @ 07:03 PM
I'm currently using Rails 2.3.8 and the resource_type on the STI/Polymorphic table isn't being set. BTW, I have the following construction:
D belongs_to :resource, :polymorphic => true
A has_many :groups, :as => :resource, :dependent => :destroy
B has_many :groups, :as => :resource, :dependent => :destroy
C has_many :groups, :as => :resource, :dependent => :destroyNote: The D model is both polymorphic and the STI bass class.
Anyway, I'm wondering, if I'm missing a step somewhere and/or this patch hasn't been applied to the 2.3.8?
-
tvongaza April 7th, 2011 @ 05:51 PM
I've updated Trek's patch to apply to v2.3.11. All AR tests still pass.
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>
Attachments
Tags
Referenced by
- 2189 count breaks has_many through association collection with named scope ok, silly question #547 here: I found the thread, found t...
- 2756 [patch] The polymorphic type field should be subclass name instead of base class name when using polymorphic association with single table inheritance For a long time it was a problem for people wanting to us...