Home > Web Developing > Ruby active link action…

Ruby active link action…

January 20th, 2009

This little code will check to see what page is current, then set the CSS color class “active”. It will make the text/link look selected and stay selected.

index.rhtml

<div id=”nav”>
         <a <% if params[:controller] == ‘name_here’ %>class=”active”<% end %>           href=”../name_here”>Link name</a>
</div>

and then make sure that you have the class “active” defined in your CSS:

main.css

#nav .active {color: #RED}

Web Developing

  1. No comments yet.
  1. No trackbacks yet.