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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:17:55+00:00 2026-05-14T22:17:55+00:00

I am trying using a partial to render the application’s menu, capitalizing the ‘tab’

  • 0

I am trying using a partial to render the application’s menu, capitalizing the ‘tab’ using CSS, based on a local variable (tab):

  <%= link_to "employees", jobs_path, :class => (tab=="employees" ? "selected":"unselected") %>
  <a class="unselected">jobs</a>
  <%= link_to "tags", tags_path, :class => (tab=="tags" ? "selected":"unselected") %>

The partial is embedded in the the Application’s layout:

<body>
...
<!-- tab variable needs to be set in the view, not the layout -->
<%= render :partial => "layouts/primary_menu", :locals => { :tab => "profiles" } %>
...
</body>

Unfortunately, I need to set the variable’s value in the view, but the variable isn’t available. Should I be using the :content_for symbol instead of :locals?

At some point, I may want to pass a model instance variable to the partial, so the solution needs to be flexible.

Is there a better approach?

  • 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-14T22:17:55+00:00Added an answer on May 14, 2026 at 10:17 pm

    I decided to make use of the link_to_unless_current UrlHelper:

    <%= link_to_unless_current "enroll", enroll_path, :class => "unselected" do
        link_to "enroll", enroll_path, :class => "selected"
    end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using rails 2.3.3 and ruby 1.9.1. I am trying to render a
hi im trying to using flashVars however for some reason there not getting sent
I'm trying to start using LINQ and specifically LINQ to SQL but I'm having
I'm trying to search using the windows search one of my web directories for
I was trying to TDD using SubSonic 2.1, MySQL and C# and when I
I have some javascript that I'm trying to retool using jQuery to learn the
Using Ruby I'm trying to split the following text with a Regex ~foo\~\=bar =cheese~monkey
trying to implement a dialog-box style behaviour using a separate div section with all
I am using D2007 and am trying to document my source code, using the
Trying to understand an fft (Fast Fourier Transform) routine I'm using (stealing)(recycling) Input is

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.