I've been trying to implement a dynamic multi-model form with accepts_nested_attributes_for
in my rails application. I've been following Eloy Duran's complex-forms example that shows a 2 level implementation, but I've been trying to expand this to 3 levels. Is there support with accepts_nested_attributes_for
for a 3 level form? Can anyone show me how to expand the example app?
I've got the javascript partially working (doesn't always work for some reason) for the 3rd level, but I can't save the 3rd level object(s). The param name it is passing for each attribute is:
greatgrandparent[grandparent_attributes][0][parent_attributes][0][object_attributes][1249277008434][attribute]
Where greatgrandparent is the object the form is for, grandparent is the first level, parent is the second level, and object is the 3rd level (the one I'm trying to save).
Thanks, I appreciate any pointers.
I have updated my complex-form-examples to work with Rails 2.3. See the deep branch for an example on deeply nested models.
git clone git://github.com/ryanb/complex-form-examples.git
cd complex-form-examples
git checkout -b deep origin/deep
rake db:migrate
script/server
It is the cleanest solution I've seen so far. If you find any bugs or improvements please add an issue on GitHub.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With