Expand errors of sub-object

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
basically do:
form_for company
fields_for user
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
How can I get detailed user error messages?
Thank you.

J. Pablo Fernández [email protected] (http://pupeno.com)

Be sure to call user.valid? in your action if the company fails so that
error messages for the user is actually generated.

<%= error_messages_for :company, :user %>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs