Try link_to_unless or link_to_unless_current.  Both accept a block through
which you could provide the alternate behavior for the "current" tab.
Assuming you have a list of tabs, you can then use each to iterate across
the tabs.

Alternatively, this is a good place to use a helper to clean up the views.

On 2/22/07, Ryan Felton <[EMAIL PROTECTED]> wrote:

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
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

Reply via email to