Changing Current Tab in Rails

后端 未结 8 1058
北荒
北荒 2020-12-28 10:05

I have a list of tabs at the top of my application that I include in a general layout in application.html.erb. They look like this:

  • 相关标签:
    8条回答
    • 2020-12-28 10:33

      I did this in the application helper and it seems to work fine:

      def current_page(path)
        "active" if current_page?(path)
      end
      

      Then call like this:

      <li class="<%= current_page(root_path)%>"> <%= link_to "Home", root_path %></li>
      
      0 讨论(0)
    • 2020-12-28 10:39

      Take a look at TabsOnRails

      0 讨论(0)
    提交回复
    热议问题