Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2560

Pure polymorphic relationships

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: 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 Unassigned
            Reporter:
            ghost Deleted user
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: