Re: validates_associated trouble

Mark Reginald James
Wed, 21 Feb 2007 23:10:14 -0000

>> validates_presence_of :sire, :if => Proc { |animal| animal.sire_id }
>
> what is Proc?? i have to write the Proc method??

A Proc is a mini function that doesn''t have a name. You can pass them
around as parameters to methods.  See:

    http://www.ruby-doc.org/core/classes/Proc.html

Note that I incorrectly capitalized "proc".  You instead
have to write either

   proc { |animal| animal.sire_id }

or

   Proc.new { |animal| animal.sire_id }