title: Rails 3: Sortable Columns
body: <p>I'm following Railscasts #228 in Rails 3.0.5 and ruby 1.9.2p180.</p>
  
  <p>I have copied code near verbatim from the verbatim with the exception of changing the class name from Product to Player. I'm also skipping the last portion where Ryan adds arrows to denote the sort direction. I'm able to load the correct index page and see all of the desired URL's with the desired parameters (direction and sort), but nothing is actually happening on click. The URL is changing, but the page is not reloading.</p>
  
  <p>Here is my code:</p>
  
  <p>ApplicationHelper</p>
  
  <pre><code>  def sortable(column, title = nil)  
      title ||= column.titleize  
      direction = (column == params[:sort] &amp;&amp; params[:direction] == "asc") ? "desc" : "asc"  
      link_to title, :sort =&gt; column, :direction =&gt; direction  
    end
  </code></pre>
  
  <p>PlayersController </p>
  
  <pre><code>  def index
      @players = Player.order(sort_column + ' ' + sort_direction)
    end
  
    private
  
    def find_team
      session[:team] ||= Team.new
    end
  
    def sort_column  
      Player.column_names.include?(params[:sort]) ? params[:sort] : "name_e"  
    end  
  
    def sort_direction  
      %w[asc desc].include?(params[:direction]) ?  params[:direction] : "asc"  
    end
  </code></pre>
  
  <p>Thanks for your help!</p>
  
  <p>Edit: As requested, HTML code. You can see that the link for Position is currently desc, as I am at: <a href="http://localhost:3000/players?direction=asc&amp;sort=abb_pos" rel="nofollow">http://localhost:3000/players?direction=asc&amp;sort=abb_pos</a>. However, no actual sorting has occurred for this column, or any other column.</p>
  
  <pre><code>&lt;th&gt;&lt;a href="/players?direction=asc&amp;amp;sort=name_e"&gt;Name&lt;/a&gt;&lt;/th&gt; 
  &lt;th&gt;&lt;a href="/players?direction=asc&amp;amp;sort=team_e"&gt;Team&lt;/a&gt;&lt;/th&gt; 
  &lt;th&gt;&lt;a href="/players?direction=desc&amp;amp;sort=abb_pos"&gt;Position&lt;/a&gt;&lt;/th&gt; 
  &lt;th&gt;&lt;a href="/players?direction=asc&amp;amp;sort=height"&gt;Height&lt;/a&gt;&lt;/th&gt; 
  &lt;th&gt;&lt;a href="/players?direction=asc&amp;amp;sort=weight"&gt;Weight&lt;/a&gt;&lt;/th&gt;
  </code></pre>