Ok, I'm stumped on arrays of form fields

My Alert object has_many Links. I’ve got the whole system setup where,
once I have the Alert object created, I can use a nice form_remote to
show the user all the Links currently attached, and add more. But the
form itself starts out with 0 links.

What I’d like to do now is construct the form with a couple of default
“Place link here” objects in the array, and show them as text fields so
that the user can overrwrite them with their own data. I successfully
did this with just one empty link by having:
<%= text_field ‘link’, ‘body’ %>

and then looking for param[:link], but I’m stumped on the whole array
syntax thing, especially when I need to prepopulate it. Do I need to
create a separate array, move the values into it, and then let the form
edit that? Do I need a variable number of link_x fields and then turn
them back and forth into an array using a loop? I’m sitting here trying
every variation of link[0], link_0, alert_link[0]… and so on that I
can think of. But it’s just not sinking in yet.

:-/

Thanks for all the help!

D

Hi Duane, I was trying to figure out the same thing a few weeks ago.
You can read about my solution here:

http://www.ruby-forum.com/topic/66264#80088

Mike