-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:
The following conventional way to build a nested form borks with Mongoid because of the lack of the above method:
<% form.fields_for :children do |child_form| %>
<!-- some fields -->
<% unless child_form.object.new_record? %>
<%= child_form.check_box '_destroy' %>
<%= child_form.label '_destroy', 'Remove' %>
<% end %>
<% end %>
This is how this stuff is implemented in AR:
- Returns ActiveRecord::AutosaveAssociation::marked_for_destruction? It's
- used in conjunction with fields_for to build a form element for the
- destruction of this association.
# - See ActionView::Helpers::FormHelper::fields_for for more info.
def _destroy
marked_for_destruction?
end
The work-around is not to call _destroy when building nested forms or to stub the method in the model. Would be clean to implement it in the library itself so this stuff works predictably.