app/views/users/index.html.erb
<section class="content-header">
</section>
<section class="content">
<div class="box">
<div class="box-header">
<h3 class="box-title">Users</h3>
<div class="box-tools pull-right">
<div class="btn-group">
<%= link_to fa_icon('upload', text: 'Import'),
import_modal_products_path,
remote: true,
class: "btn btn-box-tool disabled" %>
<%= link_to fa_icon('download', text: 'Export'),
products_path(format: :csv),
class: "btn btn-box-tool disabled" %>
<%= link_to fa_icon('plus', text: 'New'),
new_user_path,
class: "btn text-green btn-box-tool" %>
</div>
</div>
</div>
<div class="box-body">
<div class="row">
<div class='col-md-12'>
<table class="table" id="users-table" data-source="<%= users_path(format: :json)%>" >
<thead>
<tr>
<th> Name </th>
<th> Email </th>
<th> Actions </th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
<script>
$(document).on('turbolinks:load', function() {
if ($('#users-table_wrapper').length == 0) {
$('#users-table').dataTable({
"processing": true,
"serverSide": true,
"ajax": $('#users-table').data('source'),
"pagingType": "full_numbers",
"columns": [
{"data": "name"},
{"data": "email"},
{"data": "actions"}
]
// pagingType is optional, if you want full pagination controls.
// Check dataTables documentation to learn more about
// available options.
});
}
});
</script>