Within my application, I have a set of tabs displayed at the top thanks to a general layout in application.html.erb. Here's how they are structured:
<li class="current"><%= link_to "Home", provider_path(current_user.id), :method=> "GET"%> </li>
<li><%= link_to "Edit Profile", edit_student_path(current_user.id) %> </li>
<li><%= link_to "Search", provider_search_path %> </li>
My goal is to dynamically switch the selected tab to the "current" state when its respective page is accessed. So if I click on Edit Profile and land on that page, the tabs should now look like this:
<li><%= link_to "Home", provider_path(current_user.id), :method=> "GET"%> </li>
<li class="current"><%= link_to "Edit Profile", edit_student_path(current_user.id) %> </li>
<li><%= link_to "Search", provider_search_path %> </li>
I'm interested in achieving this without resorting to adding JavaScript directly to each displayed page. If there's an alternative approach, what would be the best practice for implementing it in the most efficient way possible?
Appreciate any insight.