The relation specified with the {{inverse_of}} option must have different name than relation which is about to be defined

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor - P4
    • 7.0.0, 6.2.1
    • Affects Version/s: 6.2.0
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Not sure which versions are precisely affected.

      See the attached file. One cannot define bi-directional relations like that:

      class Library
        include Mongoid::Document
        has_many :relation, class_name: "Book", inverse_of: :relation
      end
      
      class Book
        include Mongoid::Document
        belongs_to :relation, class_name: "Library", inverse_of: :relation
      end
      

      It results with inconsistent behaviour. On the assignment attempt, one side of the relation will not be saved, and sometimes stack overflow error may be raised.

        1. test.rb
          1.0 kB
        2. test.rb
          1.0 kB

            Assignee:
            Emily Stolfo (Inactive)
            Reporter:
            Sebastian Skalacki
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: