You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is useful when data is submitted via standard HTML forms encoded with the 'application/x-www-form-urlencoded' media type (which cannot represent empty collections). To work around this, a dummy item can be added to the collection with it's key set to '-1' and it will conveniently be ignored when assigned to the value object collection.
166
166
167
+
### Integrate with Cocoon
168
+
169
+
Put this into a Rails initializer (e.g. `config/initializers/value_objects.rb`):
170
+
171
+
```ruby
172
+
ValueObjects::ActionView.integrate_with :cocoon
173
+
```
174
+
175
+
This will add the `link_to_add_nested_value` & `link_to_remove_nested_value` view helpers.
176
+
Use them in place of Cocoon's `link_to_add_association` & `link_to_remove_association` when working with nested value objects:
177
+
178
+
```ruby
179
+
# use the attribute name (:addresses) in place of the association name
180
+
# and supply the value object class as the next argument
0 commit comments