I am trying to list all the users who are using my application and delete only those that i want. But every time when i try to delete my user it passes localhost:3000/users.2
instead of localhost:3000/users/2
.
And also it doesn't delete selected user rather it delete current user. But i don't want to delete current user.
I have not modified any controllers or models but only used following codes in my view to list and delete user.
<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>
Aucun commentaire:
Enregistrer un commentaire