Hi Guys,
I'm having a little bit of trouble editing multiple model objects in a single form. I've got a model Person with two attributes: name and gender. For simplicity, gender can be a text input.
I'd like to be able to display all Person objects (name and gender) in a form. So, each model object gets its own row.
In my controller, I fetch the objects with:
@people = Person.find(:all)
In my view, I loop through @people and render a form:
<% for person in @people %> <div> <span><%= person.name %>:</span> <span><%= text_field :person, :gender %></span> </div> <% end %>
I've built plenty of forms that handle attributes from a single model object. How would I edit multiple objects within a single form? In specific, I'm not sure how to set the name attribute in the gender field. And, i'm not sure how to deal with the params hash in my controller to update the models.
Thanks in advance, Raj