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

incorrectly determining inverse relationship (matching embeds_many to belongs_to)

      I have a set of documents that follow this basic relationship graph:

      class Oauth::Consumer
        include Mongoid::Document
      
        embeds_many :tokens, :class_name => 'Oauth::Token', :as => "tokenable"
      
      class Oauth::Token
        include Mongoid::Document
      
        embedded_in :tokenable, :inverse_of => :tokens
        belongs_to :consumer, :class_name => "Oauth::Consumer"
      

      The idea being that a Token can be embedded, and can additionally reference a Consumer.

      When I attempt to set consumer on a Token document mongoid determines that embeds_many :tokens is the inverse relationship to belongs_to :consumer. So, just setting the consumer causes problems since mongoid tries to set what it thinks is the inverse relationship, when there should be none.

      Shouldn't mongoid be able to determine that these are not inverse relationships because they are different types (embedded vs referenced)?

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

              Created:
              Updated:
              Resolved: