我正在构建一个管理面板,我在其中创建了一个列出已注册用户的页面。我需要创建一个链接,按ID编辑和删除用户。我不知道设计是否允许这样的操作,但可能会覆盖原始代码..
这是我在视图上的代码(当然不是在工作):
%h2 Users
%table.table.table-striped
%thead
%tr
%th Name
%th Email
%th User Type
%th Status
%th Edit
%th Delete
%tbody
- @users.each do |user|
%tr
%th= user.name
%th= user.email
- if user.user_type == 1
%th= user.user_type = "User"
- else
%th= user.user_type = "Admin"
- if user.status == 1
%th= user.status = "Active"
- else
%th= user.status = "Inactive"
%th= link_to "<i class='glyphicon glyphicon-edit'></i>".html_safe, edit_user_registration_path(current_user), :method => :put
%th= link_to "<i class='glyphicon glyphicon-trash'></i>".html_safe, registration_path(user), :confirm => "Are you sure?", :method => :delete