如何解决Rails 3表单字段未提交参数
| 我正在为我正在工作的应用程序构建一个管理部分,其中列出了业务。然后,管理员可以进入并提交电子邮件地址并启动业务。所以我在像这样的块中使用form_tag:<% for business in @businesses %>
<tr>
<td align=\"center\" class=\"border-table\"><%= business.id %></td>
<td align=\"center\" class=\"border-table\"><%= business.name %></td>
<td align=\"center\" class=\"border-table\"><%= business.address %></td>
<td align=\"center\" class=\"border-table\"><%= business.phone %></td>
<% @user = User.new %>
<%= form_tag \"/businesses/activate?business_id=#{business.id}\",:remote => true,:method => :put do %>
<td align=\"center\" class=\"border-table\" id=\"<%= business.id %>_email\"><%= text_field_tag \"email\",nil,:placeholder => \"email\" %></td>
<td align=\"center\" class=\"border-table\" id=\"<%= business.id %>_activate\"><%= submit_tag \"Activate\" %></td>
<% end %>
</tr>
<% end %>
因此,在给定的管理页面上,有25种这种形式,表中的每一行一种。
问题是,无论出于何种原因,都不会发布\“ email \”参数,而只是发布了business_id(来自路径)。
我做错什么了吗?您不应该使用一个块生成多个相似的表格吗?
任何建议将不胜感激。
谢谢!
解决方法
我想到了。似乎大多数浏览器都不会传递表单的参数,除非它位于ѭ1之内,如下所示:
<td align=\"center\" class=\"border-table\" id=\"<%= rep.id %>_email\">
<%= form_tag activate_rep_path(rep.id),:remote => true do %>
<%= text_field_tag \"email\",nil,:placeholder => \"email\",:index => rep.id %></td>
<td align=\"center\" class=\"border-table\" id=\"<%= rep.id %>_activate\">
<%= submit_tag \"Activate\" %>
<% end %>
</td>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。