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

touch: true & counter_cache not worked when nested attributes _destroy

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.1
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      when delete a record by nested attributes _destroy function, updated_at & guests_count
      of parent model is not updated.

      class Event
        fields :guests_count, type: Integer, default: 0
        has_many :guests, dependent: :destroy
        accepts_nested_attributes_for guests, reject_if: :all_blank, allow_destroy: true
      end
      
      class Guest
        belongs_to :event, counter_cache: true, touch: true
      end
      

            Assignee:
            dianna.hohensee@mongodb.com Dianna Hohensee (Inactive)
            Reporter:
            kimsuelim kimsuelim
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: