title: rails will_paginate and sorting with page caching
body: <p>I have a website where a list of products is shown in the category <code>show</code> action. I successfully paginate with the <code>will_paginate</code> gem, and make this work with page caching by configuring my routes <a href="http://seanbehan.com/ruby-on-rails/how-to-use-pretty-urls-with-rails-will_paginate-plugin/" rel="nofollow noreferrer">like Sean Behan does</a>.</p>
  
  <p>I would love to have users sort products. Currently I have a find in my controller like this:</p>
  
  <pre><code>if params[:sort_by] == "name_desc"
      #@products = Product.find_with_index("%#{params[:search]}%", :order =&gt; 'productname desc').paginate :per_page =&gt; 15, :page =&gt; params[:page]
      @products = Product.find_with_index('params[:search]')
  else
      ...
  end
  </code></pre>
  
  <p>And a simple link in my view:</p>
  
  <pre><code>&lt;%= link_to image_tag("down.gif"), category_path(:sort_by=&gt;"name") %&gt; name&lt;%= link_to image_tag("up.gif"), category_path(:sort_by=&gt;"name_desc") %&gt; 
  </code></pre>
  
  <p>My Problem is that I pass <code>?sort_by=name</code> in the URL, which doesn't work with page caching. Does anyone have an idea how can I do smarter sorting? I would really love to go on and cache pages.</p>