views:

19

answers:

1

I'm trying to validate an attribute in one model when I destroy another model. It's a complicated validation so I wrote a custom validation method. The problem is how do I call that validation method when I destroy the other model?

I'd like to be able to do something like this:

validates_associated :part, :on => :destroy

Though apparently that does not work. I've also tried doing

before_destroy self.part.validate_method

but that gives an undefined part.

Any solutions?

A: 

Hi try

before_destroy {|obj| obj.part.validate_method } 
Bohdan Pohorilets
Wow that worked! Thanks!
Audie