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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:12:24+00:00 2026-06-11T12:12:24+00:00

I have following piece of code. Here is the original post Conditionally setting CSS

  • 0

I have following piece of code. Here is the original post
Conditionally setting CSS style from ruby controller

%th{:class => @title_header}= link_to 'Title', my_path(:sort => 'title'), :id => 'title_header'

I know that the link_to work

1.I dont understand what is :class and is :class a keyword?

2.I understand that when we create a model and we will get a model_path,
but in this case why we can pass an argument into my_path?

3.Is that :sort also a keyword in rails?

4.is :id a keyword in rails?

5.so in this case , what we doing with my_path? is it going to return something?

6.how about the :id, what it does in this case??

Thankyou!

  • 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-11T12:12:25+00:00Added an answer on June 11, 2026 at 12:12 pm

    :sort and :class are symbols in Ruby, representing identifiers that don’t change in code the way a string can. They are being used as the key in a hash definition of keys/values.

    When you pass a hash of name/value pairs to a tag like %th in HAML, it convents them into HTML attributes on the tag. This allows you to dynamically set the value of the “class” attribute on the TH tag with a list of class names from the instance variable @title_header.

    my_path is a named route helper that represents a function to generate the URI for a route named in the Rails routeset. You can pass a variety of options to change how the URI is generated. By default, any option that isn’t a route generation option gets injected as a query parameter on the URI generated. So if my_path => /my/path, then my_path(:foo => ‘bar’) => /my/path?foo=bar.

    In this case, this query parameter likely dictates the sort order of the data generated at that URI.

    In the same way, the link_to function takes an option hash as it’s last argument that determines how the link element is generated. The last option set on this function is the html_options, where the attributes of the hash map to attributes of the A tag generated. In this case, the :id symbol and value in the hash will generate an “id” HTML attribute with the given value.

    Since you asked, here’s a good reference on what a CSS class is: http://www.tizag.com/cssT/class.php

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

Sidebar

Related Questions

I have the following piece of code that generate a jquerymobile-style button <a href=#
Let's say we have the following piece of code: public class Event { }
I have following piece of code: class Test{ private: int id; public: Test(int v):id(v)
I have the following piece of code: public class DumpLocationLog extends Thread { LocationManager
Here's what I want to do. I have the following piece of code: Private
I have the following piece of code which is being run from a click
I have following piece of code: It compiles without problems under gcc-3.4, gcc-4.3, intel
I have following piece of code : public Hashmap<String,String> tempmap = new HashMap<String,String>(); and
I have the following piece of code that takes in some words, stores them
I have the following piece of code in my Model: public function getSite() {

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.