Forum: Ruby on Rails how to get form parameters while using fields_for with nested attributes

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Sahil D. (Guest)
on 2009-02-09 10:32
(Received via mailing list)
hi all..

i am trying to use *fields_for* to get and save nested attributes in a
i have a 'Partner' model associated with an 'Address' model.
partner has_many :addresses

although the form is displaying fine, but on submitting it the following
error is shown:

*can't convert HashWithIndifferentAccess into Array*

on this line:

*@partner =[:partner])*

the names of main 'partner' fields are like:


the names of 'address' fields are like:


*some code:*

<% form_for(@partner) do |f| %>
  <%= f.error_messages %>
  <%= f.label :par_name, "Partner Name" %><br />
  <%= f.text_field :par_name %>
      <% f.fields_for :addresses do |addr_fields| %>
            <%= addr_fields.label :add_line_1, "Address Line 1" %><br />
            <%= addr_fields.text_field :add_line_1 %>
      <% end %>
  <%= f.submit "Create" %>
<% end %>

what's wrong over here??


Sazima (Guest)
on 2009-02-09 15:08
(Received via mailing list)
Take a look at the complex forms railscasts series (

Cheers, Sazima
Sahil D. (Guest)
on 2009-02-10 10:57
(Received via mailing list)
On Feb 9, 6:07 pm, Sazima <removed_email_address@domain.invalid> wrote:
> Take a look at the complex forms railscasts series (

thanx for the link.. now i am able to save an address along with a
partner. but the partner_id (foreign key for partner) inside address
table is not getting filled up. do i need to manually put the foreign
key, if so how do i do it.
This topic is locked and can not be replied to.