You could use a hidden tag to store the count of the fields present and iterate over each if the user is entering the name/value pairs himself. If the name value is already in there and the user is merely filling in multiple "values" for "names" which already exists, you could do:
Then iterate over each and check to see if its filled in on the controller side.
<%= NameValue.find(:all).each do |pair| -%>
<%= pair.name %>: <%= text_field_tag 'value_' pair.id.to_s, pair.value %><br />
<% end -%>
Umm... its late... do you see what I'm saying?