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

Allow custom polymorphic types

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Persistence
    • Labels:

      Mongoid supports polymorphism for has_one, has_many, embeds_one, and embeds_many. Current implementation stores parent actual class name in the child collection. For example, for this association belongs_to :unit, polymorphic: true the class name is stored in unit_type attribute.

      There is a demand to be able to infer the class name at runtime. See this article for example.

      We should allow storing arbitrary string in *_type attributes, and let the application code decide what is an actual class of the association's target.

            Assignee:
            Unassigned Unassigned
            Reporter:
            dmitry.rybakov@mongodb.com Dmitry Rybakov
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: