title: How to sort columns of a table in a Ruby on Rails Application
body: <p>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? </p>
  
  <p>Here's what I'm trying:<br>
  <strong>projects_controller.rb</strong></p>
  
  <pre><code> def index
      @projects = Project.all
      @products = Project.order(params[:sort])
  
    end
  </code></pre>
  
  <p><strong>projects.js</strong></p>
  
  <pre><code>$(document).ready(function(){
      $('/index.html.erb').DataTable();
  });
  </code></pre>
  
  <p><strong>index.html.erb</strong></p>
  
  <pre><code>&lt;thead&gt;
        &lt;tr id="headers"&gt;
          &lt;th&gt;&lt;%= link_to "Title", :sort =&gt; "title" %&gt;&lt;/th&gt;
          &lt;th&gt;&lt;%= link_to "Client", :sort =&gt; "client" %&gt;&lt;/th&gt;
          &lt;th&gt;Description&lt;/th&gt;
          &lt;th&gt;Hours&lt;/th&gt;
          &lt;th&gt;&lt;%= link_to "Done", :sort =&gt; "done" %&gt;&lt;/th&gt;
          &lt;th colspan="3"&gt;&lt;/th&gt;
        &lt;/tr&gt;
  &lt;/thead&gt;
  </code></pre>