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

前端 未结 5 993
遇见更好的自我
遇见更好的自我 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 20:50

    If you want to use a checked param you have to write this :

    check_box_tag "tag_ids[]", 1, true
    

    And not this :

    check_box_tag 'tag_ids[]', 1, true
    

    It took me a while to figure out, I hope it will help someone.

提交回复
热议问题