Implement server-side rendering of datatables in users#index

This commit is contained in:
Nishanth Vijayan 2016-08-01 02:32:48 +05:30
parent 86ba2d005e
commit caa63f9c1c
4 changed files with 66 additions and 31 deletions

View file

@ -7,7 +7,7 @@
= "(#{@users.length})"
.row
.col-md-12.table-responsive
%table.table.table-striped.table-bordered.table-hover.datatable
%table.table.table-striped.table-bordered.table-hover#userstable{data: {source: admin_users_path(format: :json)}}
%thead
%th ID
%th State
@ -18,31 +18,3 @@
%th View
%th Edit
%tbody
- @users.each do |user|
%tr
%td
= user.id
%td
- if user.confirmed?
confirmed
- else
unconfirmed
%td
= user.email
%td
= user.name
%td
= user.registrations.where(attended: true).count
%td
- unless user.get_roles.blank?
= show_roles(user.get_roles.first(2))
- if user.get_roles.count > 2
= '...'
- else
None
%td
- if can? :show, user
= link_to 'View', admin_user_path(user), class: 'btn btn-success'
%td
- if can? :update, user
= link_to 'Edit', edit_admin_user_path(user), class: 'btn btn-primary'