【发布时间】:2017-02-09 14:22:22
【问题描述】:
我正在尝试列出所有正在使用我的应用程序的用户并只删除我想要的那些用户。但是每次我尝试删除我的用户时,它都会传递localhost:3000/users.2 而不是localhost:3000/users/2。
而且它也不会删除选定的用户,而是删除当前用户。但我不想删除当前用户。
我没有修改任何控制器或模型,只是在我的视图中使用以下代码来列出和删除用户。
<table class="table table-hover table-striped">
<thead>
<tr class="bg-primary">
<th>S.N.</th>
<th>Name</th>
<th>Email</th>
<th>Created at</th>
<th>Action</th>
</tr>
</thead>
<% @users.each_with_index do |u, i| %>
<% if current_user.email != u.email %>
<tbody>
<tr>
<td><%= (@page.to_i - 1) * @perpage + i+1 %></td>
<td>
<% if u.first_name.present?%>
<%= u.first_name.slice(0, 1).capitalize + u.first_name.slice(1..-1) %>
<% end %>
<% if u.middle_name.present? %>
<%= u.middle_name.slice(0, 1).capitalize + u.middle_name.slice(1..-1) %>
<% end %>
<% if u.last_name.present? %>
<%= u.last_name.slice(0, 1).capitalize + u.last_name.slice(1..-1) %>
<% end %>
</td>
<td>
<%= u.email %>
</td>
<td>
<%= u.created_at %>
</td>
<td>
<a data-confirm="Are you sure to delete" rel="nofollow" data-method="delete" href="<%= user_registration_path(u)%>">
<span class="fa-delete">
<i class="fa fa-trash fa-th-large fa-2x"></i>
</span>
</a>
</td>
</tr>
</tbody>
<% end %>
<% end %>
</table>
当我尝试删除除 current_user 之外的其他用户时出错
【问题讨论】:
-
请看link 可能会有帮助。
-
对不起,它没有用......还有其他想法
标签: ruby-on-rails ruby ruby-on-rails-3 devise ruby-on-rails-5