I'm building a To Do List web application for a school project, and I'm trying to get the headers of the columns to be clickable and when you click them, they sort the information. I've tried so many solutions on here and google tutorials, maybe someone can help me directly?
Here's what I'm trying:
projects_controller.rb
def index
@projects = Project.all
@products = Project.order(params[:sort])
end
projects.js
$(document).ready(function(){
$('/index.html.erb').DataTable();
});
index.html.erb
<thead>
<tr id="headers">
<th><%= link_to "Title", :sort => "title" %></th>
<th><%= link_to "Client", :sort => "client" %></th>
<th>Description</th>
<th>Hours</th>
<th><%= link_to "Done", :sort => "done" %></th>
<th colspan="3"></th>
</tr>
</thead>