I was just looking at Ryan Bates railscast tutorial on Sortable Table Columns which with a few modifications becomes ajaxified in one of his later videos(Search, Sort, Paginate with AJAX). I think his solution worked great, it's clean and it degrades easily.
One problem though was the fact that he was using tables for his sorting functionality, whereas I want to use select inputs instead.
Currently I have it setup with two select boxes, one for the column and another for the search direction, as well as a link to initiate the ajax request (see below for screenshot).
However Ryan Bates had it setup so he had an individual link for each sortable column, whereas I'm only going to have one link. I was wondering if anybody knew of a way to extrapolate on what he had and merge the params with the values on a select box.
This is what I had thus far...
<table>
<tr>
<th>Sort by</th>
<th>Order</th>
</tr>
<tr>
<td>
<%= select_tag "sort", options_for_select([["Creation Date", "created_at"], ["File Name", "name"], ["Rating", "rating_average"], ["Downloads", "downloads"]]) %>
</td>
<td>
<%= select_tag "direction", options_for_select([["Descending", "desc"], ["Ascending", "asc"]]) %>
</td>
<td>
<%= link_to "Sort", params.merge(:sort => params[:sort], :direction => params[:direction], :page => nil), :class => "icon" %>
</td>
</tr>
</table>
If possible I don't want to have to restrict the functionality to only users with JavaScript enabled.