<commit_before>= Nested Form

This is a Rails gem for conveniently manage multiple nested models in a single form. It does so in an unobtrusive way through jQuery or Prototype.

This gem only works with Rails 3. See the {rails2 branch}[https://github.com/ryanb/nested_form/tree/rails2] for a plugin to work in Rails 2.

An example project showing how this works is available in the {complex-nested-forms/nested_form branch}[https://github.com/ryanb/complex-form-examples/tree/nested_form].


== Setup

Add it to your Gemfile then run +bundle+ to install it.

  gem "nested_form"

Next run the generator to create the JavaScript file. This will automatically detect if you are using jQuery or Prototype.

  rails g nested_form:install

Running the generator will add a file at <tt>public/javascripts/nested_form.js</tt> which should be included after the jQuery or Prototype framework.

  <%= javascript_include_tag :defaults, "nested_form" %>


== Usage

Imagine you have a <tt>Project</tt> model that <tt>has_many :tasks</tt>. To be able to use this gem, you'll need to add <tt>accepts_nested_attributes_for :tasks</tt> to your Project model. If you don't have the <tt>accepts_nested_attributes_for :tasks</tt> you'll get a Missing Block Error.
<commit_msg>Added note to add ":allow_destroy => true" if you want to allow destruction. Added link to accepts_nested_attributes_for documentation.<commit_after>= Nested Form

This is a Rails gem for conveniently manage multiple nested models in a single form. It does so in an unobtrusive way through jQuery or Prototype.

This gem only works with Rails 3. See the {rails2 branch}[https://github.com/ryanb/nested_form/tree/rails2] for a plugin to work in Rails 2.

An example project showing how this works is available in the {complex-nested-forms/nested_form branch}[https://github.com/ryanb/complex-form-examples/tree/nested_form].


== Setup

Add it to your Gemfile then run +bundle+ to install it.

  gem "nested_form"

Next run the generator to create the JavaScript file. This will automatically detect if you are using jQuery or Prototype.

  rails g nested_form:install

Running the generator will add a file at <tt>public/javascripts/nested_form.js</tt> which should be included after the jQuery or Prototype framework.

  <%= javascript_include_tag :defaults, "nested_form" %>


== Usage

Imagine you have a <tt>Project</tt> model that <tt>has_many :tasks</tt>. To be able to use this gem, you'll need to add <tt>accepts_nested_attributes_for :tasks</tt> to your Project model. If you wish to allow the nested objects to be destroyed, then add the <tt>:allow_destroy => true</tt> option to that declaration. If you don't have the <tt>accepts_nested_attributes_for :tasks</tt> you'll get a Missing Block Error. See the {accepts_nested_attributes_for documentation}[http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html#method-i-accepts_nested_attributes_for] for details on all available options.

{'fraction_non_alphanumeric': 0.07743881997988603, 'fraction_numerical': 0.0026818638954073082, 'mean_word_length': 4.839530332681018, 'pattern_counts': {'":': 1, '<': 27, '<?xml version=': 0, '>': 29, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1111639', 'n_tokens_mistral': 872, 'n_tokens_neox': 814, 'n_words': 366}