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 8087873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:55:09+00:00 2026-06-05T18:55:09+00:00

I want to sort the items that have been previously selected with checkboxes. If

  • 0

I want to sort the items that have been previously selected with checkboxes. If I select ratings for movies by clicking the checkboxes, it returns the movies that apply.

The end of the URL looks like this:

?ratings[PG-13]=1&ratings[G]=1  

If I click on the link that orders the movies, it takes the whole list of movies and not the ones that I just targeted. So, how can I “append” "sort=title" to the ratings in the URL?

I have a feeling it’s something I can do in the view. My link_to is this:

%th#title_header{:class=>("hilite" if @sort == "title")}= link_to "Movie Title", :sort =>   "title"

and my check_box_tag is this:

= check_box_tag "ratings[#{rating}]",rating,@all.include?(rating)

In my controller, I have this:

def index

@movies = Movie.order(params[:sort])
@movies = @movies.where(:rating => params[:ratings].keys) if params[:ratings].present?
@sort = params[:sort]
@all = (params[:ratings].present? ? params[:ratings] : [])

end

(I know, my “where” query is vulnerable to SQL injection, it’s temporary, I’m just trying to conceptualize the whole thing.)

  • 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-05T18:55:10+00:00Added an answer on June 5, 2026 at 6:55 pm

    You need to pass an extra hash at the end of link_to ,it chains the queries in the url:

    link_to "Movie Title", movies_path(:sort => "title", :ratings => params[:ratings])
    

    Brilliant!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been developing an application that can publish content like some sort of
I have a ListView (GridView) that I want to sort by 2 columns, so
I want to sort items where the comparison is performed by humans: Pictures Priority
Lets say I want to sort some items and need to sort them by
I have a log file named a.log ! I want sort it by the
I want a sort of overlay after clicking on a button. This is how
I have an applications that stores players ratings for each tournament. So I have
I have a list of items that are in this format: 05/01 – Some
I have an XML file whose contents I want to sort by document order
I have a form with over 100 list items that I must reorder on

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.