RAIRS-在仍在使用application.html.erb的特定页面上时,您如何使导航链接保持在特定页面上,以保持导



在Ruby上的Ruby(5((5(您如何在仍在使用Application.html.erb的特定页面上保持NAV链接以保持导航链接?

例如:

application.html.erb

<nav class="nav">
    <li><%= link_to "Home", root_path, :class => 'na' %></li>
    <li><%= link_to "Units", units_path, :class => 'ACTIVE' %></li> 
</nav>

也许很简单:

<%= link_to 'Units', units_path, class: "#{'active' if controller_name == 'units' && action_name == 'index'}" %>

最新更新