1

I created a simple rails app: :~ rails generate scaffold User name:string email:string :~ rake db:migrate and then edited _form.html.erb for using the DataTable Plugin:

<table id="users" class="display">
<thead>
<tr>
  <th>Name</th>
  <th>Email</th>
  <th>Update</th>
</tr>
</thead>
<tbody>
<tr>
<%= form_for(@user) do |f| %>
  <% if @user.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>

  <ul>
  <% @user.errors.full_messages.each do |msg| %>
    <li><%= msg %></li>
  <% end %>
  </ul>
</div>
<% end %>

<td><div class="field">
  <%= f.label :name %><br />
  <%= f.text_field :name %>
</div></td>
<td><div class="field">
  <%= f.label :email %><br />
  <%= f.text_field :email %>
</div></td>
<td><div class="actions">
  <%= f.submit %>
</div></td>
<% end %>
</tr>
</tbody>
</table>

The form works completely well when a User is created. But, when i try update User's information it returns me a routing error: No route matches [POST] "/users/1"

For Update the call should have been PUT but it is using POST here. It only happens when I use the Gem otherwise the Update is working fine. Please look into the following matter.

Issue Link :here

4

1 回答 1

0

遇到同样的问题。必须通过使用来解决它,:include_id => false以便rails 不会生成隐藏:id字段,然后在其中一个 td 中手动添加隐藏字段。

于 2013-10-19T03:43:19.100 回答