title: Rails 4 - Sortable Records
body: <p>Im trying to make an app with Rails 4.</p>
  
  <p>I'm trying to follow this tutorial on how to sort the model by column names:</p>
  
  <p><a href="http://railscasts.com/episodes/228-sortable-table-columns" rel="nofollow">http://railscasts.com/episodes/228-sortable-table-columns</a></p>
  
  <p>The tutorial may be out of date.</p>
  
  <p>I've tried to make my controller match the tutorial, as follows:</p>
  
  <pre><code>helper_method :sort_column, :sort_direction
  
    # GET /organisations
    # GET /organisations.json
    def index
      @organisations = Organisation.order(sort_column + " " + sort_direction)
    end
  
   def sort_column
        Organisation.column_names.include?(params[:sort]) ? params[:sort] : "title"
      end
  
      def sort_direction
        %w[asc desc].include?(params[:direction]) ? params[:direction] : "asc"
      end
  </code></pre>
  
  <p>Application_helper has:</p>
  
  <pre><code>module ApplicationHelper
  
      def sortable(column, title = nil)
        title ||= column.titleize
        css_class = column == sort_column ? "current #{sort_direction}" : nil
        direction = column == sort_column &amp;&amp; sort_direction == "asc" ? "desc" : "asc"
        link_to title, {:sort =&gt; column, :direction =&gt; direction}, {:class =&gt; css_class}
      end
  end
  </code></pre>
  
  <p>I add this to my organisations index show page:</p>
  
  <pre><code>&lt;td&gt;&lt;span class="intpolth"&gt;&lt;%= sortable "name" %&gt;&lt;/span&gt;&lt;/td&gt;
  </code></pre>
  
  <p>When I try this, I get the following error:</p>
  
  <pre><code>undefined method `sortable' for #&lt;#&lt;Class:0x007f9a3c54e0b0&gt;:0x007f9a39efd460&gt;
  </code></pre>
  
  <p>Can anyone see what's wrong? or know a better way to sort by column name?</p>