GFunk913
1/16/2006 2:37:00 AM
I have a situation where I want to edit an arbitrary instances of one
model on one page. I can and have accomplished this by manually
managing the object <-> text field relationship, but in a way I
consider at best hackish. I'd like to know a clean way to do this.
If you want to edit the name attribute on a person class, you write
code like this
text_field("person","name")
Say I have an array in variable @people. What my mind feels is the
logical thing to do is
for i in 0...n
p = "people[" + i.to_s + "]"
text_field(p,"name")
end
That might be the "ugly" way to do it but you get the idea. I want to
put N text fields on the screen, each corresponding to the name
attribute on a different person object. However, that doesn't work for
me.
Does anyone have a good/most-often-used idiom for doing this? Help
would be appreciated. Thanks.