lib/generators/breadko/templates/views/index.html.erb
<section class="content-header">
</section>
<section class="content">
<div class="box">
<div class="box-header">
<h3 class="box-title"><%= object.camelize %></h3>
<div class="box-tools pull-right">
<div class="btn-group">
<%%= link_to "Add <%= object.camelize %>", new_<%= object %>_path, class: "btn btn-primary" %>
</div>
</div>
</div>
<div class="box-body">
<div class="">
<table class="table" id="<%= objects %>-table" >
<thead>
<tr>
<% attributes.each do |attribute| -%>
<th><%= attribute.name.titleize %> </th>
<% end -%>
<th> Actions </th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</section>
<script>
$(document).on('turbolinks:load', function() {
$('#<%= objects %>-table').dataTable({
"processing": true,
"serverSide": true,
"ajax": $('#<%= objects %>-table').data('source'),
"pagingType": "full_numbers",
"columns": [
<% attributes.each do |attribute| -%>
{ "data": "<%= attribute.name %>" },
<% end -%>
{ "data": "actions", "sortable": false }
]
// pagingType is optional, if you want full pagination controls.
// Check dataTables documentation to learn more about
// available options.
});
});
</script>