Editing N instances of a model on one page

G

GFunk913

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,202
Messages
2,571,055
Members
47,659
Latest member
salragu

Latest Threads

Top