Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Polymorphic Associations & STI don't record the correct model type

#547

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?

Reported by ronin-18882 (at lighthouseapp) · July 3rd, 2008 @ 08:35 PM

State: wontfix
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Pratik
    Pratik
    • State changed from new to incomplete
    • Assigned user set to Pratik

    The patch is missing tests.

    Thanks.

    July 4th, 2008 @ 12:18 AM

  2. Pratik
    Pratik
    • State changed from incomplete to wontfix

    Closing till any progress is made.

    August 3rd, 2008 @ 02:34 PM

  3. Trek
    Trek

    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.

    April 13th, 2010 @ 05:06 AM

  4. Conrad Taylor
    Conrad Taylor

    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 => :destroy

    Note: 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?

    January 28th, 2011 @ 07:03 PM

  5. bingbing
  6. tvongaza
    tvongaza

    I've updated Trek's patch to apply to v2.3.11. All AR tests still pass.

    April 7th, 2011 @ 05:51 PM