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

  • SEARCH
  • Home
  • 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 5955223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:05:00+00:00 2026-05-22T18:05:00+00:00

I am working on the index page of a listing controller, which needs several

  • 0

I am working on the index page of a listing controller, which needs several sort options. Query string is needed to determine the sort option that is active for the current page. I have used a workaround for this problem by hardcoding the query string into the sort links:

=link_to "Lowest Price","/listings?sort_by=price&order=asc", :class=>"#{'active' if request.query_string =~ /sort_by=price&order=asc/ }"

But there are two problems with this. First, this is too fragile. Second, it doesn’t support a search query nor any other parameters — otherwise it breaks.

What I need is a way to change the sort options without assuming that the query string will stay intact…

Not sure if there is a best practice for doing this. I’m taking the long road and just adding helpers to parse url to hash, hash to url, and I still don’t know what to do about the active link problem. It could be a while to do all that.

Any suggestions would be appreciated.

  • 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-05-22T18:05:00+00:00Added an answer on May 22, 2026 at 6:05 pm

    You can do this by providing key/value pairs to any URL helper. For example:

    listings_url(:sort_by => "asc", :order => "asc")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been working on a small application recently which consists of an index page
i have a dynamic php web page localhost/ctd/index.php All working good except if i
I have an index page for listing products. From this page I would like
I want to create an index page for which I need the page number
I am working with a custom MVC PHP framework and the index page (acting
I have a working Lucene index supporting a suggestion service. When a user types
I am working through the SDL tutorials over at http://lazyfoo.net/SDL_tutorials/index.php and I'm stuck on
I am working with the following piece; def index @user = User.find(params[:id]) rescue flash[:notice]
I am working with the sample Home application project on http://developer.android.com/resources/samples/Home/index.html I've added another
my htaccess rule isn't working with rewrite with dashes in: RewriteRule ^([A-Za-z]+)$ index.php?do=$1 [QSA]

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.