Created
August 22, 2011 09:31
-
-
Save dbackeus/1162014 to your computer and use it in GitHub Desktop.
Referenced document frozen on childs after_destroy callback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Parent | |
include Mongoid::Document | |
field :something, :type => String | |
has_many :children | |
after_create :create_child | |
private | |
def create_child | |
children.create | |
end | |
end | |
class Child | |
include Mongoid::Document | |
belongs_to :parent | |
after_destroy :update_parent | |
private | |
def update_parent | |
parent.update_attributes(:something => "value") | |
end | |
end | |
Parent.create.children.first.destroy |
Author
dbackeus
commented
Aug 22, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment