Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8236485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:08:58+00:00 2026-06-07T19:08:58+00:00

I was just looking at Ryan Bates railscast tutorial on Sortable Table Columns which

  • 0

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).

Desired functionality

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:09:00+00:00Added an answer on June 7, 2026 at 7:09 pm

    AFAICS, params from select-tags will come through in pretty much the same way as any other param – so merging them should work the same way. The only difference is that you need to pass params[:sort] into the select-tag. Have a look at how you pass in the currently-selected-value here:

    http://apidock.com/rails/ActionView/Helpers/FormTagHelper/select_tag

    and

    http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/options_for_select

    Which suggests a format:

    <%= select_tag "sort", options_for_select([["Creation Date", "created_at"], ["File Name", "name"], ["Rating", "rating_average"], ["Downloads", "downloads"]], params[:sort]) %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just looking at this answer , which contains the code for Nullable<T>
I am just looking to write some annotation which can execute at runtime, before
Just looking at: (Source: https://xkcd.com/327/ ) What does this SQL do: Robert'); DROP TABLE
Just looking for some advice.. I have two websites on IIS7 which are seperate
I'm just looking around for starting learning NDK, with one particular project in mind:
Just looking for some advice on this one, what exactly is a loading screen
Hi just looking for some direction, I have a HTML form which has several
Just looking for the best practise way of doing this. I have a table
Just looking for a good PHP Image Library, I want to display images with
Just looking on resources that break down how frames per second work. I know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.