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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:24:20+00:00 2026-06-16T16:24:20+00:00

I am rendering my main top navigation in a loop in Rails 3: <ul>

  • 0

I am rendering my main top navigation in a loop in Rails 3:

<ul>
<% Placement.all.each do |placement| %>
  <li><%= link_to placement.placementname, placement_path(placement.id)%> </li>
<%end%>
</ul>

How can I highlight the background of the current placement based on the id in the url? the url looks like this:
localhost:3000/placements/1
localhost:3000/placements/2
…

Once the user clicks on one of those tabs a second navigation bar will appear on the left side. This is how I am rendering it:

<% @placement.ads.all.each do |ad| %>
    <li><%= link_to ad.adname, placement_ad_path(@placement, ad) %> </li>
<%end%>

How can I highlight the background of the current ad based on the id in the url? the url looks like this: localhost:3000/placements/1/ads/1
localhost:3000/placements/2/ads/3
…

  • 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-16T16:24:21+00:00Added an answer on June 16, 2026 at 4:24 pm
    <ul>
     <% Placement.all.each do |placement| %>
       <li class=<%= "highlighted" if placement.id==params[:id].to_i %>>
           <%= link_to placement.placementname, placement_path(placement.id)%> </li>
     <%end%>
    </ul>
    

    and

    <% @placement.ads.all.each do |ad| %>
      <li class=<%= "highlighted" if ad.id==params[:id].to_i %>>
        <%= link_to ad.adname, placement_ad_path(@placement, ad) %> </li>
    <%end%>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm rendering a form. I would like to put a mark next to all
i am about to port all my rendering from old opengl to glsl. now
I have an existing Rails site which is rendering very poorly on iPhone and
I'm trying to render two different scenes and cameras on top of each other,
I am using Google Web Fonts. All browsers are rendering the font properly except
Rendering the same html in IE and Firefox gives me a different result because
While rendering the view page, based on some condition in the controller action I
I'm having trouble rendering out a template, my data looks like this: var data
I'm successfully rendering a polygon shaped window. However, I would like to outline it
I'm rendering this Cmenu but the active class isn't showing on the li element

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.