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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:27:42+00:00 2026-06-01T20:27:42+00:00

So I have this in my application.html.erb file: <div class=mainMenu> <%= link_to ‘Movies’, dvds_path

  • 0

So I have this in my application.html.erb file:

<div class="mainMenu">
<%= link_to 'Movies', dvds_path %>  
<%= link_to 'Books', books_path %>  
<%= link_to 'Albums', cds_path %> 
<%= link_to 'Games', games_path %> 
</div>

I would like to put a class of “highlight” on the menus if we are on each of the pages, so for example, in the Movies page, if we are in dvds_path then it would be:

<%= link_to 'Movies', dvds_path, :class => 'highlight' %>

But can’t seem to figure it out, none of these methods worked for me:

using the controller

using a helper

Any help 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-06-01T20:27:44+00:00Added an answer on June 1, 2026 at 8:27 pm

    You could use:

    link_to_unless_current(name, options = {}, html_options = {}, &block)
    

    Creates a link tag of the given name using a URL created by the set of options unless the current request URI is the same as the links, in which case only the name is returned (or the given block is yielded, if one exists). You can give link_to_unless_current a block which will specialize the default behavior (e.g., show a “Start Here” link rather than the link’s text).

    http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to_unless_current

    So you could style your ‘links’ as unselected in your nav bar, and have a ‘selected’ style when the link is not present..

    li { color:#fff; } /* selected */
    li a { color:#333; }
    li a:hover { color:#999; }
    
    <ul id="navbar">
      <li>Home</li>
      <li><a href="/controller/about">About Us</a></li>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application.html.erb file which sets out layout for every pages in my
I have several partials that I'm including in my Rails application.html.erb file , but
I'm learning RoR through this tutorial . In tute, an application.html.erb file is created
In my global.css file which is loaded by application.html.erb , I have the following
I have this file: app/views/listings/list.html.erb in my rails project. Here are the contents of
I have this file: geoView.html.erb <meta name=viewport content=initial-scale=1.0, user-scalable=no /> <%= stylesheet_link_tag 'application' %>
In my ASP MVC 3 application, I have this form @using (Html.BeginForm()) { <input
I have this application with 2 classes, in the first class I define a
I have this chunk on jQuery and currently its living in my index.html.erb and
I've installed devise on my app and applied the following in my application.html.erb file:

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.