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}