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

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.
allen (Guest)
on 2007-04-25 14: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.