- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要能够创建一个表单,其中有几个 text_field_tags 根据另一个模型的实例动态创建。我希望能够将输入到这些 text_field_tags 的值存储到同一个数组中,一旦提交表单,我就可以作为 Controller 中的参数访问该数组。这可能吗?
最佳答案
如果您给它们都赋予相同的名称并在末尾附加 [],如下所示:
<%= text_field_tag "some_fields[]" %>
<%= text_field_tag "some_fields[]" %>
<%= text_field_tag "some_fields[]" %>
some_fields = params[:some_fields] # this is an array
<%= text_field_tag "some_fields[1]" %>
<%= text_field_tag "some_fields[2]" %>
<%= text_field_tag "some_fields[3]" %>
关于ruby-on-rails - Ruby On Rails : How do I create multple text_field_tags that store the values into the same array?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12188436/
我有如下功能 var resultObject = { testResult: $('.test').map(function() { return {
我的模拟数据: [ { "id": 1, "first_name": "Suzy", "last_name": "Pinnell", "email": "spinn
每个方法有多个 try{}catch{} 语句是一种好习惯吗? 最佳答案 在我看来,让每个方法只处理一个任务是一种很好的做法。因此,您很少需要在一个方法中使用多个 try/catch block 。但
Linux,C.我创建了多个线程来运行工作负载,我想在指定的秒数/超时后通知这些线程停止/终止。我如何用 C 实现它? void *do_function(void *ptr) { //cal
我需要能够创建一个表单,其中有几个 text_field_tags 根据另一个模型的实例动态创建。我希望能够将输入到这些 text_field_tags 的值存储到同一个数组中,一旦提交表单,我就可以
背景:我专门为 ASP.NET 应用程序使用存储过程。我正在使用 DataReader 加载数据集对象。 最佳答案 单个过程返回单个结果(为了代码的可维护性、简单性和过程的重用),然后一次调用调用所有
我是一名优秀的程序员,十分优秀!