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

Callback before_save called twice

    XMLWordPrintable

    Details

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

      Description

      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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: