使用accepts_nested_attributes_for在rails中使用三级嵌套表单

Ano*_*non 7 javascript forms ajax ruby-on-rails nested-forms

我一直在尝试accepts_nested_attributes_for在我的rails应用程序中实现动态多模型表单.我一直在关注Eloy Duran的复杂形式示例,该示例显示了2级实现,但我一直在尝试将其扩展到3个级别.是否支持accepts_nested_attributes_for3级表格?谁能告诉我如何扩展示例应用程序?

我已经让第三级的javascript部分工作(并不总是因某种原因而工作),但是我无法保存第3级对象.它为每个属性传递的参数名称是:

 greatgrandparent[grandparent_attributes][0][parent_attributes][0][object_attributes][1249277008434][attribute] 
Run Code Online (Sandbox Code Playgroud)

如果greatgrandparent是表单所用的对象,祖父母是第一级,父级是第二级,对象是第3级(我想要保存的那个).

谢谢,我感谢任何指针.

rya*_*anb 18

我已经更新了我的复杂表单示例以使用Rails 2.3.有关深层嵌套模型的示例,请参阅深分支.

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
Run Code Online (Sandbox Code Playgroud)

这是迄今为止我见过的最干净的解决方案.如果您发现任何错误或改进,请在GitHub上添加一个问题.