Forum: Ruby on Rails How can I deal with collections in fieldset?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1292dfc5df2064e008f7f12b9c56561d?d=identicon&s=25 allen (Guest)
on 2007-04-25 12:51
(Received via mailing list)
Hi all,

I have a very complex model which has several has_one and has_many
relationships with other models. For the has_one relations, I can use
"field_for" to create/update the model information in a single form.
But how can I deal with the has_many relations? I know that if I what
to have collections in a form, the following code will work:

<% form_tag do %>
  <% for @product in @products %>
    <%= text_field("product[]", 'image_url') %><br />
  <% end %>
  <%= submit_tag %>
<% end %>

But how can I do this using "fields_for"? Thanks a lot.
This topic is locked and can not be replied to.