I know there has to be a way to do this.  Is there any way to edit a
model, and its has_many children in a single view?

Example:

class Metadata
 has_many :metadata_entries
end

If both Metadata and MetadataEntries have a 'label' attribute, what
would the view look like?

Here is my best guess, but this doesn't work:
------edit.html.erb----

<% form_for(@metadata) do |f| %>
   <%= f.text_field :label %>
   <p>try to marshal the data for each "metadata_entry" has_many
relationship</p>
   <% @metadata.metadata_entries.each_with_index do |entry, index| %>
      <p>this is obviously wrong, how do I index this??</p>
      <input type="text"
name="metadata[metadata_entries][<%=index%>][label]"
value="<%=entry.label%>"/>
   <% end %>
   <%= f.submit 'Update' %>
<% end %>

------end edit.html.erb----

I'm running ruby 1.8.6/Rails 2.3.2.

Thanks in advance for any and all pointers.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to