Best way to highlight current page in Rails 3? — apply a css class to links conditionally

后端 未结 8 1770
野趣味
野趣味 2020-12-04 14:25

For the following code:

<%= link_to \"Some Page\", some_path %>

How do I apply a css class current using the

8条回答
  •  旧时难觅i
    2020-12-04 14:48

    I'd do it this way :

    <%= link_to "Some Page", some_path, :class => current_page? ? "current" : "" %>
    

提交回复
热议问题