2011-04-06 63 views
1

这是我的代码,我浪费了很多时间在这个,但仍然没有得到答案。表单结束在同一行开始,并因为这个提交方法没有添加数据库中的复选框值。请帮助?窗体没有在表内导致更新方法正确结束导致更新方法

< table> 
    <% pos = 0%> 
    <% @accounts.each do |myacc| %> 
    <% if @accounts.length == pos +1 %> 
     <tr class="last"> 
    <% else%> 
     <tr> 
    <% end %> <!-- end of if tag --> 
    <td class="position"><%= pos += 1%>.</td> 
    <td ><%= myacc.name %>< /td> 
    < % form_for(:account,:html =>{:method =>:put,:id =>"editAccountForm_"+pos.to_s,:multipart => true}) do|f|%> 
     <td> 
     <% if myacc.place_matching == "1" %> 
      <input type="checkbox" id=place_matching value=1 checked="checked" /> 
     <% else %> 
      <input type="checkbox" id=place_matching value=0 /> 
     <% end %> <!-- end of if tag -->             
     </td> 
     <td> 
     <% if myacc.data_pulling == "1" %> 
      <input type="checkbox" id="data_pulling" value=1 checked="checked" /> 
     <% else %> 
      <input type="checkbox" id="data_pulling" value=0 /> 
     <% end %> <!-- end of if tag --> 
     </td> 
     <td> 
     <a class="gray-button gray-whitebg" href="#" onclick="getElementById('editAccountForm_<%= pos%>').submit();return false;" />ADD</a> 
     </td> 
    <% end %> <!-- end of form tag --> 
    </tr> 
    <% end %> 
</table> 

回答

-1

,请复制粘贴您的完整形式..

,请把你从表格形式列出了..

希望这将有助于

+1

这不是一个答案。请使用请求的评论 – Yule 2011-04-06 08:39:27

+0

@Yule ..你是对的.. – 2011-04-06 08:44:07

+0

@yule。有一个沟通不畅。我想你在更新我的答案时看到了我的答案。 – 2011-04-06 08:52:11

0

在轨道3,你总是有使用<%= %>形式,也为块。 所以写

<%= form_for ... 

我看你使用form_for,但随后没有使用f可言。为什么不使用f.check_box?见documentation。 或使用form_tag,然后使用。请参阅documentation

你应该使用更多的助手钢轨给你。