added sort for users list
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
module Admin
|
||||
class UserController < AdminController
|
||||
def index
|
||||
@users = policy_scope User.order(:name)
|
||||
@users = policy_scope User.order("#{sort_column} #{sort_direction}")
|
||||
.page(params[:page])
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -52,5 +53,9 @@ module Admin
|
||||
def user_params
|
||||
params.require(:user).permit(policy(User).permitted_attributes)
|
||||
end
|
||||
|
||||
def sort_column
|
||||
User.column_names.include?(params[:sort]) ? params[:sort] : 'name'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Email</th>
|
||||
<th>Role</th>
|
||||
<th><%= sortable "name", "User" %></th>
|
||||
<th><%= sortable "email" %></th>
|
||||
<th><%= sortable "role" %></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
|
Reference in New Issue
Block a user