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

Autosave on Parent objects is by default

      It looks like in Mongoid 3.0.15 all the way through 3.1.4, parent relationships are always saved.

      In the Mongoid documentation section for autosaving, it only documents the autosaving of child objects, but not parent objects.

      This can cause somewhat of a problem for people not expecting this (migrating from 2.x)
      For example:

      class User
        has_many :posts, :autosave => false # (this is documented to be false by default)
      end
      
      class Post
        belongs_to :user, :autosave => false # (this is not documented AFAIK, but is true by default)
      end
      

      This actually caused us some pain causing some cascading saves upward. For example, if User belong to some other entity, then triggering a save on a Post will trigger a save on User and so on upwards.

      This should probably either be documented or defaulted to false.

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

              Created:
              Updated:
              Resolved: