<commit_before># cocoon

[![Build Status](https://travis-ci.org/nathanvda/cocoon.png)](https://travis-ci.org/nathanvda/cocoon)

Cocoon is a Rails 3 gem that makes it easier to handle nested forms.

Nested forms are forms that handle nested models and attributes in one form;
e.g. a project with its tasks or an invoice with its line items.

Cocoon is form builder-agnostic, so it works with standard Rails, [Formtastic](https://github.com/justinfrench/formtastic), or [SimpleForm](https://github.com/plataformatec/simple_form).

This project is not related to [Apache Cocoon](http://cocoon.apache.org/).

## Prerequisites

This gem depends on jQuery, so it's most useful in a Rails 3 project where you are already using jQuery.
Furthermore, I would advise you to use either [Formtastic](https://github.com/justinfrench/formtastic) or [SimpleForm](https://github.com/plataformatec/simple_form).

## Installation

Inside your `Gemfile` add the following:

```ruby
gem "cocoon"
```

For Rails 4.0 use version from github:
```ruby
gem "cocoon", :git => "git://github.com/nathanvda/cocoon"
```

### Rails 3.1+

Add the following to `application.js` so it compiles to the asset pipeline:

```ruby
//= require cocoon
```

### Rails 3.0.x

If you are using Rails 3.0.x, you need to run the installation task (since rails 3.1 this is no longer needed):

```bash
rails g cocoon:install
```

This will install the Cocoon JavaScript file. In your application layout, add the following below the default javascripts:<commit_msg>Adapted README to show we are now compatible with rails 4.<commit_after># cocoon

[![Build Status](https://travis-ci.org/nathanvda/cocoon.png)](https://travis-ci.org/nathanvda/cocoon)

Cocoon makes it easier to handle nested forms.

Nested forms are forms that handle nested models and attributes in one form;
e.g. a project with its tasks or an invoice with its line items.

Cocoon is form builder-agnostic, so it works with standard Rails, [Formtastic](https://github.com/justinfrench/formtastic), or [SimpleForm](https://github.com/plataformatec/simple_form).
It is compatible with rails 3 and rails 4.

This project is not related to [Apache Cocoon](http://cocoon.apache.org/).

## Prerequisites

This gem depends on jQuery, so it's most useful in a Rails 3 project where you are already using jQuery.
Furthermore, I would advise you to use either [Formtastic](https://github.com/justinfrench/formtastic) or [SimpleForm](https://github.com/plataformatec/simple_form).

## Installation

Inside your `Gemfile` add the following:

```ruby
gem "cocoon"
```


### Rails 3.1+

Add the following to `application.js` so it compiles to the asset pipeline:

```ruby
//= require cocoon
```

### Rails 3.0.x

If you are using Rails 3.0.x, you need to run the installation task (since rails 3.1 this is no longer needed):

```bash
rails g cocoon:install
```

This will install the Cocoon JavaScript file. In your application layout, add the following below the default javascripts:
{'fraction_non_alphanumeric': 0.10780046869768999, 'fraction_numerical': 0.008034817542684968, 'mean_word_length': 4.553903345724907, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 12, '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': '3897204', 'n_tokens_mistral': 991, 'n_tokens_neox': 905, 'n_words': 362}