Rails复选框和参数 [英] Rails checkbox and params

查看:176
本文介绍了Rails复选框和参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面中使用了许多复选框,如下所示:

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

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

想象一下,它从1到20,所有都与更改的值相同。如何在控制器中获取被检查的 params

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?

示例:如果用户检查3 ,5和10如何在单个参数中获得那些参数?

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

推荐答案

em>得到只有那些被检查;未选中的框不会发送到服务器。

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

这篇关于Rails复选框和参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆