For existing objects you can use the objects id for an index, for new
objects just use some kind of counter. When you submit the form the
index objects will be rolled up into a hash that you can then step
through and process.
The :index value needs to be unique for each object. If he objects
already exist the id works great, otherwise you need to create a
unique key for each object. The code below uses the counter loop
variable for the :index value.
# wrap everything in a form_for
<%= form_for ........ %>
# loop to create multiple objects
<% 3.times do |counter| %>
# setup fields for each object
<% fields_for posts, post do |post_fields| %>
# use the counter variable for the :index key
<%= post_fields.select :rating, @ratings, {}, {:index =>
counter} %>
<%= post_fields.text_field :name, :index => counter %>
<% end %>
<% end %>
<% end %>
I plan on using rjs insert_html for each additional object beyond one
that the user wants to create. The reason why I am doing it this way
is because the objects that are created, each will have the same
foreign key (mapped to a different model). If their all going to have
the same foreign keys, I think it makes sense to create them all on
the same form/view.