Implementing Nested Forms in Rails with nested_assignment

Posted by Lance Ivy Sun, 14 Dec 2008 23:22:00 GMT

Two days ago I created a plugin to add nested model assignment to Rails. After adding it into my current project and dealing with some implementation issues, I can safely say that it works.

Ryan Bates created a sample application to showcase different attempts at solving nested forms, and asked that I apply the plugin to demonstrate how it works. You can see how my plugin works at http://github.com/cainlevy/complex-form-examples/tree/cainlevy. Note that you need to checkout the cainlevy branch and initialize git submodules. Also please understand that I have not written anything yet to help create the form, and so all of the raw implementation logic is very exposed.

If you download and run the sample application, try disabling JavaScript! Everything should still be quite functional. The packaged JavaScript (written in jQuery) adds some nice usability though.