Should Associations::Preloader allow subclasses not to define the association?


I am working a project where subclasses (using STI) of an model have different relationships. Quick Example:

class Course < ActiveRecord::Base

has_many :learning_units, as: :container


class LearningUnit <ActiveRecord::Base


class LessonGroup < LearningUnit

belongs_to :container, polymorphic: true

has_many :lessons,

        -> { where(container_type: },
        class_name: "Lesson",
        foreign_key: "container_id"


class Lesson < LearningUnit

belongs_to :container, polymorphic: true

notice no lessons relationship


Everything works as expected except that when I try to do


an exception is raised because one of the subclasses does not have a lessons relationship.

This is where it happens:

Unless I am mistaken, there’s no configuration to change this behaviour. A possible fix would be to raise the exception only if none of the classes define the requested associations. Is there any chance such a change gets merged?

Any thoughts are more than welcome.