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

does 'autosave' in many to many rel trigger before_save callback?

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

      I was wondering if autosave triggers any save or update callbacks on the referenced document. It seems not to be doing so. Is it expected behavior? e.g.:

      class Product
        include Mongoid::Document
        has_and_belongs_to_many :customers, autosave: true
        before_save :do_stuff
      
        def do_stuff
          # never called
        end
      end
      
      class Customer
      
        include Mongoid::Document
        has_and_belongs_to_many :products, autosave: true
      
      end
      
      Customer.create! products: [Product.first]
      Product.first.customers.count  # => 1
      # But it never calls do_stuff
      

      Thanks!

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

              Created:
              Updated:
              Resolved: