Callbacks: parent_id is nil when child is destroyed via nested attributes

XMLWordPrintableJSON

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

      Very similar to MONGOID-2127 except it also happens with referenced relations.

      class Page
        has_many :components
        accepts_nested_attributes_for :components, :allow_destroy => true
      end
      
      class Component
        belongs_to :page
        after_save :touch_page
        
        def touch_page
          page.touch
        end
      end
      

      When a nested component is given field _destroy = 1 and the page object is saved, the component callback is fired but returns undefined method 'touch' for nil:NilClass. It seems like page_id is getting wiped too soon. Same for after_destroy too. Is this normal?

      mongoid (3.0.5)
      rails (3.2.2)

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

              Created:
              Updated:
              Resolved: