Embedded documents can't save with referenced documents.

XMLWordPrintableJSON

    • None
    • None
    • None
    • None
    • None
    • None
    • None

      This is related to https://github.com/mongoid/mongoid/issues/1653

      class Referenced
      include Mongoid::Document
      belongs_to :inner
      end

      class Inner
      include Mongoid::Document
      has_one :referenced
      validates_presence_of :referenced
      embedded_in :outer
      end

      class Outer
      include Mongoid::Document
      embeds_one :inner
      end

      Now, when I try and save an Outer with an Inner, the Inner does not save - because the Referenced could never have a valid id. I understand the rationale behind this, but would it be possible to detect this pattern and throw an error somewhere? Maybe checking for :embedded_in and :has relation on the same document?

      Thanks!

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

                Created:
                Updated:
                Resolved: