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

Callback before_save called twice

    • Type: Icon: Task Task
    • Resolution: Done
    • 5.0.0
    • Affects Version/s: None
    • Component/s: None

      Is such behavior expected:

      class Train
        include Mongoid::Document
        embeds_one :place
      end
      
      class Place
        include Mongoid::Document
        embedded_in :train
      
        before_save do
          puts "place saved"
        end
      end
      
      > train = Train.create
      > train.create_place
      place saved
      place saved
      

      callback was called twice. How can I avoid this double callback call?

      P.S. mogoid 3.1.6

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

              Created:
              Updated:
              Resolved: