Selective validation? Is it possible?

Hello Petr,

I have a Product model and products table. Im using acts_as_tree structure. I would like active record validation to be done on children only. Anyway to do this?

The root product is the product who has no parent. So in your validation, you could pass an :if option and a condition in the block :

:if => Proc.new { |r| r.parent }

Example : validates_presence_of :name, :if => Proc.new { |r| r.parent }

   -- Jean-François.