Skip to content

Commit d0b41b2

Browse files
committed
add comment to explain intention in member_params
1 parent 577c05e commit d0b41b2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

app/controllers/concerns/member_concerns.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ def member_params
1313
:pronouns, :name, :surname, :email, :mobile, :about_you, :skill_list, :newsletter, :other_dietary_restrictions,
1414
dietary_restrictions: [],
1515
).tap do |params|
16+
# We want to keep Rails' hidden blank field in the form so that all dietary restrictions for a member can be
17+
# removed by submitting the form with all check boxes unticked. However, we want to remove the blank value
18+
# before setting the dietary restrictions attribute on the model.
19+
# See Gotcha section here:
20+
# https://api.rubyonrails.org/v7.1/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_check_boxes
1621
params[:dietary_restrictions] = params[:dietary_restrictions].reject(&:blank?) if params[:dietary_restrictions]
1722
end
1823
end

0 commit comments

Comments
 (0)