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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:54:25+00:00 2026-06-12T07:54:25+00:00

I have the following type of page setup: Header – Consistent Left side –

  • 0

I have the following type of page setup:

Header – Consistent
Left side – contains <%= yield %>
Right side – ul that contains mostly static menu

So, what I would like to do is
a) add a class to the current page li. So for example, when on the about page, about li on the right adds .current

and b) show sub-menu on right side for current page. So if li is about.current, I could show a sub-menu inside that li.

The layout is there for every page (as is the purpose of the application layout), and not every page is listed in the menu on the right. So, the question is can I pass a variable or a call that will pass the page name to the application layout to allow for adding .current or what is the best way to deal with something like this? Is the answer to just not include the right menu bar in the application layout, even though I would then need to add it to every page?

Looking for suggestions.

  • 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-12T07:54:26+00:00Added an answer on June 12, 2026 at 7:54 am

    The current_page? helper method can tell you if a url is for the current page. So you could do something like the following:

    <li><%= link_to "Something", something_url, :class => (current_page?(something_url) ? "current" : "") %></li>
    

    Even better, you could define a helper method that will do that automatically:

    def link_to_with_current_class(name, url, options = {})
      if current_page?(url)
        if options[:class]
          options[:class] += " current"
        else
          options[:class] = "current"
        end
      end
      link_to(name, url, options)
    end
    

    And then:

    <li><%= link_to_with_current_class "Something", something_url %></li>
    

    http://apidock.com/rails/ActionView/Helpers/UrlHelper/current_page%3F

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

Sidebar

Related Questions

When using ASP.net webforms my usual solution would have following type of setup -
So I have the following function on a page that is supposed to be
I have following type of data ntrt = paste (EL, 1:4, sep= ) repl
I have the following: type KEY = (IPv4, Integer) type TPSQ = TVar (PSQ.PSQ
I have the following type of object : [RateInfo] => stdClass Object ( [@rateChange]
I have the following type in wsdl (it is generated by third party tool):
I have the following simple type: module Structures type Point2D<'T> (x : 'T, y
I have declared the following type KEY = (IPv4, Integer) type TPSQ = TVar
I have the following code: Type type = typeof(T); foreach (PropertyInfo pi in type.GetProperties(BindingFlags.Public
I have the following case where I want to accept the following routs '/type/view/23'

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.