nathanvda/cocoon — pull request #223 by dnagir (2014-07-11 06:28:54+00:00)
Title: Allow to use with simple arrays without AR

This complements already accepted PR I sent a while ago
https://github.com/nathanvda/cocoon/pull/90

That PR allowed using cocoon on ActiveRecord models
with nested Array items.
But still the main form object had to be ActiveRecord.

This commit removes that restriction and allows
using cocoon with plain ActiveModel-compliant objects
(including the object for the main form).

This has been requested in the issue below but went unnoticed
https://github.com/nathanvda/cocoon/issues/141

Usage example (model only side)

```ruby

class User
include ActiveAttr::Model
attribute :email
end

class Company
include ActiveAttr::Model

def users
@users ||= []
end

# This will allow setting the attributes from `fields_for` rails helper
# when the form will be posted
def users_attributes=(attrs)
# update the users array...
end

# cocoon uses this method to render the template
def build_user
User.new # blank state for new template
end
end

```

@nathanvda, I would appreciate if you could merge this in and maybe release the gem when possible so that I can make use of it in my project.