How to mark a link in a layout menu as "active" in rails?

Posted by Erik Escobedo on Stack Overflow See other posts from Stack Overflow or by Erik Escobedo
Published on 2010-06-07T16:28:51Z Indexed on 2010/06/07 16:32 UTC
Read the original article Hit count: 359

Filed under:

I have a ul filled with links in my layout/application.html.erb and want the current location link be marked with class="active".

Now I'm using:

<%= link_to 'About Us', { :controller => 'aboutus' }, :class => "menu#{' active' if params[:controller] == 'aboutus'}" %>

But it looks pretty nasty to me.

Anyone has a better idea?

© Stack Overflow or respective owner

Related posts about ruby-on-rails