views:

11

answers:

1

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?

+1  A: 

You can use the helper method similar to link_to

its called "link_to_unless_current".

http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html ( find the details here )

HTH

Rishav Rastogi
Holy cow! Thank you, that was exactly what I needed!
Erik Escobedo