Be sure to call user.valid? in your action if the company fails so that the
error messages for the user is actually generated.
<%= error_messages_for :company, :user %>
On 9/30/07, J. Pablo Fernández
<pupeno-GAtDADarczzQT0dZR+AlfA@public.gmane.org>
wrote:>
>
> Hello,
> I have two models, let''s call them Company and User. A company
belongs_to
> a
> user and a user has_one company (for now, may has_many latter). Currently
> I''m
> using one form to create both a user and a company at the same time, so I
> basically do:
> form_for company
> fields_for user
> ...form...
> and then I do:
> @company = Company.new params[:company]
> @company.user = User.new params[:user]
>
> The problem is that when I do error reporting with:
> <%= error_messages_for :company %>
> I don''t get detailed field by field errors of users, only
"User is
> invalid".
> How can I get detailed user error messages?
> Thank you.
> --
> J. Pablo Fernández <pupeno-GAtDADarczzQT0dZR+AlfA@public.gmane.org>
(http://pupeno.com)
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---