Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

support for nested attributes with dynamic number of elements #213

merged 1 commit into from Apr 24, 2012


None yet
4 participants

pkmiec commented Nov 1, 2011

Rebased as one commit.

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,


we can specify validation for all email_address fields simply as,


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

astjohn commented Dec 1, 2011

This is a great addition that works for my dynamic fields. Thanks!


pkmiec commented Dec 1, 2011


I'm not really sure what's holding up the pull request, though.


bcardarella commented Dec 1, 2011

I've been busy and haven't had the time to review the pull request, sorry.


pkmiec commented Dec 1, 2011

Thanks for the update.


bcardarella commented Mar 29, 2012

@pkmiec I'm very sorry I let this go stale. Can you please rebase so I can merge?


pkmiec commented Mar 31, 2012

@bcardarella rebased ... there are test failures but the same failures occur on master.

This sounds like what I need too. I'm using Cocoon to dynamically add nested fields and the validations aren't being performed. The validation is a custom, remote validation. Interestingly, even when I'm editing a pre-existing object with nested objects already added the validations still aren't being performed. However, if I try and set the same validation on a top-level attribute, the validation works perfectly.

I'm hoping this will solve my problem and maybe I'll just wait until there's an update before worrying about it.

@bcardarella bcardarella added a commit that referenced this pull request Apr 24, 2012

@bcardarella bcardarella Merge pull request #213 from pkmiec/nested_attributes
support for nested attributes with dynamic number of elements

@bcardarella bcardarella merged commit 291e4f7 into DavyJonesLocker:master Apr 24, 2012


bcardarella commented Apr 24, 2012

Totally forgot about this, merged in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment