Skip to content
gavinhughes edited this page Sep 12, 2010 · 7 revisions

before destroy not working correctly

I’m using before_destroy to test the presence of children in a class using awesome_nested_set, but all the children are destroyed before before_destroy is called. Any suggestions on a fix or a way around this?

before_destroy :error_if_subregions

def error_if_subregions
   raise "Region contains subregions" unless children.empty?
end

Gavin