Skip to content

Commit

Permalink
Fixes #53
Browse files Browse the repository at this point in the history
Explanation of why this only occurs now: The previous rails version ignored invalid ids
for `accepts_nested_attributes_for` parameters, the new one doesn't.
-> We need to avoid sending them.
  • Loading branch information
lentschi committed Jul 26, 2024
1 parent b39cb77 commit 51c2703
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/assets/javascripts/article-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,11 @@ class ArticleForm {
const id = $(`[name="${this.unitFieldsNamePrefix}[article_unit_ratios_attributes][${index}][id]"]`, this.articleForm$).val();
row$.remove();

$(this.unitRatiosTable$).after($(`<input type="hidden" name="${this.unitFieldsNamePrefix}[article_unit_ratios_attributes][${index}][_destroy]" value="true">`));
$(this.unitRatiosTable$).after($(`<input type="hidden" name="${this.unitFieldsNamePrefix}[article_unit_ratios_attributes][${index}][id]" value="${id}">`));
if (id != null) {
$(this.unitRatiosTable$).after($(`<input type="hidden" name="${this.unitFieldsNamePrefix}[article_unit_ratios_attributes][${index}][_destroy]" value="true">`));
$(this.unitRatiosTable$).after($(`<input type="hidden" name="${this.unitFieldsNamePrefix}[article_unit_ratios_attributes][${index}][id]" value="${id}">`));
}

this.filterAvailableRatioUnits();
this.updateUnitMultiplierLabels();
this.setFieldVisibility();
Expand Down

0 comments on commit 51c2703

Please sign in to comment.