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.

It should be invalid to go :through a polymorphic belongs_to

#6212

Consider the following:

    class Tagging
      belongs_to :taggable, :polymorphic => true
      has_many :something, :through => :taggable
    end

Obviously the something association on the taggable might only be available at certain times, depending on what the taggable actually is.

At the moment, the above example fails, because it tries to look up the source reflection, which involves getting the through_reflection.klass, which doesn't exist.

Whilst it would be theoretically possible to support the above, it's basically insane. I suggest we add in a HasManyCantAssociateThroughPolymorphicBelongsToReflection and raise it properly in ThroughReflection#check_validity!.

Reported by Jon Leighton · December 22nd, 2010 @ 10:18 PM

State: resolved
Milestone: 3.x
Assigned to: Jon Leighton Jon Leighton
Importance: Low