Rails表单更新索引部分内的记录

时间:2015-01-04 16:10:29

标签: ruby-on-rails

你们可以告诉我这里我做错了什么。我正在尝试允许用户更新索引中的某些字段。但是,当我按下屏幕上的按钮进行更新时,没有任何反应,数据库中的记录保持不变。我错过了什么或做错了什么?

  

视图/ company_pays / _index.html.erb

<h1>Company Pays</h1>

<table class="table">
  <thead>
    <tr>
      <th>Description</th>
      <th>Type</th>
      <th>Units</th>
      <th>Apply deduction1</th>
      <th>Apply deduction2</th>
      <th>Apply deduction3</th>
      <th>Apply deduction4</th>
      <th colspan="3"></th>
    </tr>
  </thead>

  <tbody>
    <% @company_pays.each do |company_pay| %>
      <tr>        
        <td><%= company_pay.description %></td>
        <td><%= company_pay.pay_sub_head.short_desc %></td>

      <td class="input"><%= form_for company_pay, :method => :patch do |f| %></td>
        <% if company_pay.errors.any? %>
          <div id="error_explanation">
            <h2><%= pluralize(company_pay.errors.count, "error") %> prohibited this company_pay from being saved:</h2>

            <ul>
            <% company_pay.errors.full_messages.each do |message| %>
              <li><%= message %></li>
            <% end %>
            </ul>
          </div>
        <% end %>  
        <td class="input"><%= f.text_field :units %></td>
        <td class="input"><%= f.check_box :apply_deduction1 %></td>
        <td class="input"><%= f.check_box :apply_deduction2 %></td>
        <td class="input"><%= f.check_box :apply_deduction3 %></td>
        <td class="input"><%= f.check_box :apply_deduction4 %></td>
        <td class="actions"><%= f.submit "Update" %>
      <% end %>
        </td>


      </tr>
    <% end %>
  </tbody>
</table>

感谢您寻找

0 个答案:

没有答案