Pure polymorphic relationships

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Won't Fix
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      A polymorphic relationship is dependant of the type of relationship (referenced or embedded) and this bring up situations when you are restricted to defining two different polymorphic classes for the same "behaviour" when working with both kinds of relationships.

      This means that polymorphic relationships in mongoid are really: "Embedded polymorphic" and "Referenced polymorphic".

      What if it could be possible to do this:

      class Business
      include Mongoid::Document
      has_many :addresses, as: :addressable
      end

      class Person
      include Mongoid::Document
      embed_one :address, as: :addressable

      class Address
      include Mongoid::Document
      polymorphic_on :addressable
      end

      Address could act as a referenced or embedded at runtime depending on context beign called.
      I know that it is a big change but it could be interesting if mongoid plans to maintain referenced behaviour in the future

            Assignee:
            Unassigned
            Reporter:
            Deleted user
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: