Rails checkbox and params

大兔子大兔子 提交于 2019-12-23 11:44:23

问题


I am using many checkboxes in a page as the following:

<%= check_box_tag(:one, value = 1) %></p>

Imagine that it goes from 1 to 20, all the same with the value changed. How can I get in the controller the params of the ones that were checked?

Example: If user checks 3, 5 and 10 how can I get just those params in a single params?


回答1:


You'll already get only the ones that were checked; unchecked boxes aren't sent to the server.



来源:https://stackoverflow.com/questions/7870090/rails-checkbox-and-params

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!