The check_box_tag
indeed does not use the hidden field so it does not send anything in case the box is unchecked (unlike the check_box
helper, which is nevertheless still not useful in case of an array param, as Meier notes above).
If you are trying to use your checkbox in a similar way as in this SO question (i.e. to send a user-selected array of ids for example), the simple solution might be to react on an empty param in the controller. Something in the way of:
params[:apply] ||= []
If, on the other hand, you wanted to use the checkboxes as an ordered array where each value would be determined by its constant position in the array, either true or false, (i.e. if you wanted to get something like this in the apply
param: [0, 1, 0, 0, 1]
), this wouldn't work. You'd have to choose a different approach, e.g. use the checkboxes with a hash param instead of array.