2011-04-06 64 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

你應該使用更多的助手鋼軌給你。