Repeatable Form Elements

Does anyone know any good "recipe" to have repeatable form elements in Ruby on Rails sites?

As an example, let's say I want users to be able to add as many addresses as possible. An address object consists of two address lines, a city id, and a country id. They can click "Add Another Address" and more address inputs are created on the fly.

Javascript - Extending forms - imagine this as an example

1. How do you set the names of the form elements in rails so that they are processed easily? Can you even do this with helpers, or would the necessary elements need to be written and parsed manually? ex. address[:city], address[:state]

2. Is there an easy way to keep track of addresses on the page once they are added, assuming they can be updated in text fields? For example, after someone adds an address, and reloads the page, can you say: address[1][:city], or some other name and then have Rails parse this correctly as an object in the params? This would need to also be differentiated from the naming convention in #1, to differentiate existing address objects from new ones.

Anyone have any ideas or articles that deal with this issue, or hints on how to make this easier?

Thanks.

I think this episode might help you...

See those same Railscasts to which shenry cited David Schwartz for one way to do multiple object creation on a single form: