我创建了一个简单的rails app::~ rails generate scaffold User name:string email:string :~ rake db:migrate,然后编辑_form.html.erb以使用DataTable插件:
<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>当创建用户时,表单工作得非常好。但是,当我尝试更新用户信息时,它返回一个路由错误:没有与POST "/users/1“匹配的路由
对于Update,调用应该是PUT,但它在这里使用的是POST。只有当我使用Gem时才会发生这种情况,否则更新会运行得很好。请调查以下事项。
问题链接:here
发布于 2013-10-19 11:43:19
遇到了同样的问题。我不得不使用:include_id => false来解决这个问题,这样rails就不会生成隐藏的:id字段,然后在其中一个td中手动添加一个隐藏字段。
https://stackoverflow.com/questions/16501440
复制相似问题