RubyFlow : The Ruby Community Blog

Home   Submit   Sign Up   Log In   leaders   Twitter   RSS Feed  
 

Awesome Nested Fields for Rails

In Rails, you can create forms that have fields from nested models. For example, if a person has many phone numbers, you can easily create a form that receives data from the person and from a fixed number of phones. However, when you want to allow the person to insert multiple, indefinite phones, you're in trouble: it's much harder than it should be. Well, not anymore. Check the awesome demo or the project code. =)

Comments

The code does not work in the demo. The place drop down does not change to the saved value if editing the form. E.g make a phone number work. Save it and then edit it - the drop down says Home still :(Anonymous Coward - September 07, 2011 14:23
I got the same problem. But it's pretty easy to fix it. Replace with .

I did a pull request on github to fix it.

BTW, awesome work :)Anderson Dias - September 07, 2011 15:12
Nice Anderson. Pull request applied and app updated. Thanks!lailsonbm - September 07, 2011 15:54
I mean this as a genuine question and not a criticism, but how does this differ from Ryan Bates' nested_form gem? https://github.com/ryanb/nested_formLeo Cassarani - September 07, 2011 17:34
In fact, I started this project one year ago for an app that uses this nested fields a lot. In that time, I looked for some gems, including nested_form, but we need more things, like performing some validations before inserting fields and manipulate them dynamically. So the main difference is that awesome_nested_fields includes callbacks and an API for the JS. Another minor difference is that awesome_nested_fields focus more on the client side. For example: there is no methods to create an add or remove link. But I'm really grateful to Ryan Bates for his screencasts, specially the two about Nested Forms, that are the base of this gem. =)lailsonbm - September 08, 2011 14:34

Post a Comment

Note: If you are a registered user, you can log in to populate these fields.

You may use ONLY these HTML tags to format your comment:

<a href="" title=""> <b> <blockquote> <code> <em> <i> <strong>

Do NOT use <p> tags. Just use newlines :-)

t
I bum
a
g
U willy
u
O bum
r
i
c
l
a
s
s