public
Description: Various ways to handle multi-model forms in Rails.
Homepage:
Clone URL: git://github.com/ryanb/complex-form-examples.git
name age message
file .gitignore Fri Jul 18 14:10:24 -0700 2008 initial import [ryanb]
file LICENSE Fri Jul 18 14:10:24 -0700 2008 initial import [ryanb]
file README.rdoc Tue Aug 04 16:49:23 -0700 2009 improving readme [ryanb]
file Rakefile Fri Jul 18 14:10:24 -0700 2008 initial import [ryanb]
directory app/ Wed Aug 05 12:09:43 -0700 2009 adding remove link instead of checkbox [ryanb]
directory config/ Mon Aug 03 17:51:03 -0700 2009 updating to Rails 2.3.3 [ryanb]
directory db/ Tue Aug 04 16:16:33 -0700 2009 adding solution for deeply nested models [ryanb]
directory doc/ Fri Jul 18 14:10:24 -0700 2008 initial import [ryanb]
directory public/ Wed Aug 05 12:11:10 -0700 2009 fixing css selector for fields [ryanb]
directory script/ Fri Jul 18 14:10:24 -0700 2008 initial import [ryanb]
directory test/ Tue Aug 04 16:16:33 -0700 2009 adding solution for deeply nested models [ryanb]
README.rdoc

Complex Form Example: Deep Nesting

This solution uses the accepts_nested_attributes_for which was introduced in Rails 2.3. It supports any level of depth in nesting models. The primary challenge in deep nesting is getting the escaping working with JavaScript when adding new records.

Once you clone this repository, just run the migrations and start up the server to try it out.

  rake db:migrate
  script/server

See the branches for alternative solutions. Here’s how to clone a remote branch.

  git checkout -b deep origin/deep