On Mar 1, 2011, at 4:12 PM, Todd A. Jacobs wrote:

> I'm running into an error where validation of a child form fails
> because there's no ID yet for the parent record. Job is a child of
> address, where a job:
> 
>  belongs_to :address
> 
>  validates :address_id,
>            :presence => true,
>            :numericality => true
> 
> and "children :jobs" is defined in address.rb. However, trying to save
> the record fails, claiming that "Address can't be blank."
> 
> In regular Rails, I'd solve this problem by using the build method,
> but I'm not sure how to solve the problem with Hobo. It seems that
> validating children would be built-in; I'm sure I'm missing something
> obvious.

There was a relevant thread along these lines on rails-core a while back:

http://groups.google.com/group/rubyonrails-core/browse_frm/thread/6d168ad6dd061574?hl=en#

The consensus was that validating the *object* (:address here) is better, as 
:address_id could be set to an integer that doesn't correspond to a real record 
and still pass the above.

--Matt Jones

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to