[Sdruby] Conditionally setting the class in a view

Ryan Felton ryanfelton at gmail.com
Fri Feb 23 06:08:21 GMT 2007


I have a tab navigation and I'm trying to set the active tab based on
the page that the customer is viewing. Currently its a bunch of if
else statements, but I know there has to be a way to shorten it.

<% if request.symbolized_path_parameters[:controller] == 'main' %>
	<%= link_to 'Home', {:controller => 'main', :action => 'show' },
:class => 'active' %>
<% else %>
	<%= link_to 'Home', {:controller => 'main', :action => 'show' } %>
<% end %>

Thanks,

Ryan


More information about the Sdruby mailing list