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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:59:30+00:00 2026-05-24T18:59:30+00:00

I’m following Railscasts #228 in Rails 3.0.5 and ruby 1.9.2p180. I have copied code

  • 0

I’m following Railscasts #228 in Rails 3.0.5 and ruby 1.9.2p180.

I have copied code near verbatim from the verbatim with the exception of changing the class name from Product to Player. I’m also skipping the last portion where Ryan adds arrows to denote the sort direction. I’m able to load the correct index page and see all of the desired URL’s with the desired parameters (direction and sort), but nothing is actually happening on click. The URL is changing, but the page is not reloading.

Here is my code:

ApplicationHelper

  def sortable(column, title = nil)  
    title ||= column.titleize  
    direction = (column == params[:sort] && params[:direction] == "asc") ? "desc" : "asc"  
    link_to title, :sort => column, :direction => direction  
  end

PlayersController

  def index
    @players = Player.order(sort_column + ' ' + sort_direction)
  end

  private

  def find_team
    session[:team] ||= Team.new
  end

  def sort_column  
    Player.column_names.include?(params[:sort]) ? params[:sort] : "name_e"  
  end  

  def sort_direction  
    %w[asc desc].include?(params[:direction]) ?  params[:direction] : "asc"  
  end

Thanks for your help!

Edit: As requested, HTML code. You can see that the link for Position is currently desc, as I am at: http://localhost:3000/players?direction=asc&sort=abb_pos. However, no actual sorting has occurred for this column, or any other column.

<th><a href="/players?direction=asc&amp;sort=name_e">Name</a></th> 
<th><a href="/players?direction=asc&amp;sort=team_e">Team</a></th> 
<th><a href="/players?direction=desc&amp;sort=abb_pos">Position</a></th> 
<th><a href="/players?direction=asc&amp;sort=height">Height</a></th> 
<th><a href="/players?direction=asc&amp;sort=weight">Weight</a></th>
  • 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-24T18:59:31+00:00Added an answer on May 24, 2026 at 6:59 pm

    Found the issue. I had the following code in my player model:

    Player.rb

    default_scope :order => 'name_e'
    

    As a result, the SQL search generated looked like this:

    SELECT `players`.* FROM `players` ORDER BY name_e, avg_points desc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a view passing on information from a database: def serve_article(request, id): served_article
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

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.