In Rails, how to handle multiple checked checkboxes, just split on the , or?

前端 未结 5 981
遇见更好的自我
遇见更好的自我 2020-12-02 20:43

Curious what the \'rails way\' of handling the situation when a user checks multiple checkboxes (with the same name value), and it gets posted back to the controller.

<
5条回答
  •  再見小時候
    2020-12-02 21:05

    f.check_box :tag_ids, {multiple: true}, 1, nil
    

    Is the right answer:

    Here is the reason, there is a 'multiple: true' option that allows your input to be placed in an array. If there isn't a multiple: true option this will not be allowed.

提交回复
热议问题