This is more difficult than I originally anticipated. Any help in
figuring this out is most appreciated:
This is a code snippet from my header.rhtml (or erb) file that draws
tabbed menus:
<ul>
<% [["Home", "/home" ],
["Positions", "/company" ],
["Leads", "/feed" ],
["Calendar", "/calendar"],
["Contacts", "/contact" ],
["Documents", "/document"],
["My Account", "/account" ],
["Help", "/help" ]].each do |label,
controller| %>
<%= open_tag “li” %>
<%= link_to_unless_current(label,
{:controller => controller}
) { |label, controller| content_tag(“span”, label,
:class => “current”) } %>
This implements “tabbed menus” using special CSS styling for the
“current” class and works fine.
Here is the twist: each of the tabs, Home for example which has
corresponding controller given by “/home” displays pages using default
index action which has further links pointing back to other controllers.
So a link in the page opened by HomeController index action has a link
pointing back to the CompanyController (identified above by
[“Positions”, “/company” ] sub-array.
As it is now, as soon as the users click on the links on any pages, the
current tab disappears since there is no “current” class. Instead, when
the users click on a link on the page displayed by the index action,
they still want the “Home” tab hilighted to show the navigation path
which means it should have the “current” class. In this case,
link_to_unless_current does not work since there is not current tab or
link that was clicked on.
How should I go about implementing that?
Bharat