bcardarella/client_side_validations — pull request #212 by pkmiec (2011-11-01 07:53:25+00:00)
Title: Added support for fields_for with dynamic nested attributes

Since the validations for each nested attribute are the same, there is no need to have them repeated for each model. Instead, the validations can be specified once for all the nested attributes and then applied to fields at any index.

For example, given users that accepts nested attributes for emails, the form will contain the following fields,

user[email_attributes][0][email_address]
user[email_attributes][1][email_address]
user[email_attributes][2][email_address]
user[email_attributes][N][email_address]

we can specify validation for all email_address fields simply as,

user[email_attributes][][email_address]

This not only sends less data to the client but also works with dynamic forms (i.e. press + to add another email address field).