-1
我創建了一個基於Pundit作爲枚舉的3個不同角色的網站,用戶可以是分析師,開發人員或管理員。Admin Page Ruby on Rails
我有一個控制器系統與一個動作,users_list。
def users_list
@users = User.order(:id).page params[:page]
authorize @users
end
而波紋管是我的看法。 高清users_list @users = User.order(:ID)。第PARAMS [:頁面] 授權@users 結束
<%- model_class = User -%>
<div class="page-header">
<h1><%=t '.title', :default => model_class.model_name.human.pluralize.titleize %></h1>
</div>
<table class="table table-striped">
<thead>
<tr>
<th><%= model_class.human_attribute_name(:id) %></th>
<th><%= model_class.human_attribute_name(:email) %></th>
<th><%= model_class.human_attribute_name(:role) %></th>
<th><%= model_class.human_attribute_name(:created_at) %></th>
<th><%=t '.actions', :default => t("helpers.actions") %></th>
</tr>
</thead>
<tbody>
<% @users.each do |user| %>
<tr>
<td><%= link_to user.id, edit_user_registration_path(user) %></td>
<td><%= user.email %></td>
<td><%= user.role %></td>
<td><%=l user.created_at %></td>
<td>
<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
cancel_user_registration_path(user),
:method => :delete,
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
:class => 'btn btn-xs btn-danger' %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= link_to t('.new', :default => t("helpers.links.new")),
new_user_registration_path,
:class => 'btn btn-primary' %>
我想知道的是我怎麼可以在這個頁面允許管理員改變用戶的角色。