On 6/21/07, Phillip Baker
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> Hey All,
>
> I have a form that submits data to multiple models.
>
> I have
>
> class Man < ActiveRecord::Base
> has_many :notes
> has_many :contacts
>
> validates_associated :contacts, :notes
> validates_presence_of :first_name
> validates_presence_of :last_name
>
> class Contact < ActiveRecord::Base
> belongs_to :man
>
> validates_presence_of :contact_info
>
> class Note < ActiveRecord::Base
> belongs_to :man
>
> validates_presence_of :notes
>
> However when I submit the form blank, it will only validate for the Man
> model. Not the other two. If I fill in the form then the data gets
> submitted to the DB tables just fine, it just will not validate more
> than that base model.
From: <
http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000948>
"NOTE: This validation will not fail if the association
hasn''EURO~t been
assigned. If you want to ensure that the association is both present and
guaranteed to be valid, you also need to use
validates_presence_of<http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000941>
. "
What am I missing??>
> Blessed Be
>
> Phillip
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--
Matt H <matt.haley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---