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

Manipulations with associations ignores validation

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 3.1.3
    • Component/s: None
    • Labels:
      None

      Description

      I have next classes
      <pre><code> class A
      include Mongoid::Document
      has_many :bs
      validates :bs, presence: true
      end

      class B
      include Mongoid::Document
      belongs_to :a
      end

      a = A.new
      a.valid? #false
      a.bs << B.new
      a.valid? #true
      B.count #0
      A.count #0
      a.save
      B.count MONGOID-4
      A.count MONGOID-4
      a.bs = []
      a.valid? #false
      A.first.bs.count #0, but I expect 1 record to be here
      </code></pre>

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            Surzhko Surzhko [X] (Inactive)
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: