Skip to content

Instantly share code, notes, and snippets.

@zhhz
Created February 11, 2009 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhhz/62107 to your computer and use it in GitHub Desktop.
Save zhhz/62107 to your computer and use it in GitHub Desktop.
#I am not sure if this is the feature(it is designed to do so),
# or I'm doing it wrong. Here is the situation I have:
# as of DM version: 0.9.9
class Order
before :destroy, :destroy_items
....
has n, items ...
def destroy_items
# NOT working
# this by pass the item's before destroy hook
# items.destroy!
# this part is working, the :check_xxx is called
items.each |item| do
...
item.destroy
end
end
end
class OrderLineItem
...
before :destroy, :check_xxx
belongs_to :order
def check_xxx
raise "the_error_message" if xxxxx
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment