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

Repeatedly call validate method ?

    XMLWordPrintable

    Details

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

      Description

      Hi there, here is my test code:

      class A
        include Mongoid::Document
        
        embeds_many :bs, cascade_callbacks: true
      end
       
      class B
        include Mongoid::Document
       
        embedded_in :a
       
        validate { puts "validate from B object" }
      end
       
      a = A.new
      a.bs.build()
      a.valid?
       
      # Output
      Validate from B object
      Validate from B object
      =>  true
      

      The validate method has been called twice. After I removing the cascade_callbacks: true option, it seems work well.

      I don't think there is any need to call the validate method repeatedly.

        Attachments

          Activity

            People

            Assignee:
            durran Durran Jordan
            Reporter:
            zhouguangming zhouguangming
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: