Tuesday, January 26, 2010

[Rails] Re: accepts_nested_attributes_for :has_many :through => 'bug?'

Thanks for having a look Matt, I've changed

<% f.fields_for :companies do |company| %>

to

<% f.fields_for :companies_attributes do |company| %>

and i'm no longer getting the "expected object, but got array error",
now i'm getting
"undefined method `stringify_keys' for "test":String" where "test" was
the company name i inputted into the form. Below is the html output of
the form.

<form action="/users" class="new_user" id="new_user" method="post">
<p><label for="First_name">First name</label>
<input id="user_firstname" name="user[firstname]" size="30"
type="text" value="" /></p>

<p><label for="Surname">Surname</label>
<input id="user_surname" name="user[surname]" size="30" type="text"
value="" /></p>

<p><label for="email">Email</label>
<input id="user_email" name="user[email]" size="30" type="text" /></
p>

<p><label for="password">Password</label>
<input id="user_password" name="user[password]" size="30"
type="password" /></p>

<p><label for="password_confirmation">Confirm Password</label>
<input id="user_password_confirmation" name="user
[password_confirmation]" size="30" type="password" /></p>

<hr />
<h2>Company Information</h2>

<input id="user_companies_attributes_name" name="user
[companies_attributes][name]" size="30" type="text" />


<p class="submit"><input name="commit" type="submit" value="Sign
up" /></p>
</form>

--
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@googlegroups.com.
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate