Nested attributes plugin: remove _remove/_delete flags from attributes #455

Merged
merged 2 commits into from Mar 26, 2012

Projects

None yet

2 participants

@r-stu31

HTML forms with checkboxes for removing/deleting of associations also supply 'false' values. This leads to complications - one needs to have a "blank" _remove/_delete setters or set Model.strict_param_setting = false.

Provided fix solves the problem by removing the flags from attributes hash. I've made two decisions, which you may want to reconsider:

  • the removing is done on a dup of the original hash to preserve it
  • i've reordered the conditions to remove the flags only if the corresponding settings (reflection[:nested_attributes][:remove] resp. reflection[:nested_attributes][:destroy]) apply
r-stu31 added some commits Mar 24, 2012
@r-stu31 r-stu31 Add tests for updating associated objects with _delete/_remove flags …
…set to false.
dbe1e41
@r-stu31 r-stu31 Avoid complications with _delete/_remove flags being passed to nested…
…_attributes_update if they are set to false: remove the _delete/_remove flags from attributes if deleting/removing the associated objects is configured. Do not modify the original attributes hash.
945ef98
@jeremyevans
Owner

This looks good. I should have time to merge and test it on Monday. Thanks for the help!

@jeremyevans jeremyevans merged commit 945ef98 into jeremyevans:master Mar 26, 2012
@r-stu31 r-stu31 deleted the r-stu31:nested_attributes-_remove-_delete branch Jul 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment