Re: validates_associated doesn''t actually validate anything

AJ Schuster
Thu, 16 Jun 2005 18:24:46 -0000

On 6/16/05, Scott Barron <scott-HDQKq3lYuGDk1uMJSBkQmQ@public.gmane.org>
wrote:
>
> If you need to use the id numbers you''ll probably need to write
your
> own custom validation code, otherwise you could do something like:
>
> c = Contract.new
> c.site = Site.find(params[:site_id])
> c.customer = Customer.find(params[:site_id])
> c.save
>
> and handle any errors occuring there (e.g. find throwing
> RecordNotFound, or using any of the other finders and their errors).

Scott-

Thanks for the suggestion. That worked perfectly.

Upon rereading the documentation for validates_associated, I suppose
this behavior makes sense.

AJS