For the following code:
<%= link_to \"Some Page\", some_path %>
How do I apply a css class current
using the
In my case I have a lot of name spaced controllers, that is why I like to show if the current view also is in the Menu Path, I had use the solution of Michael van Rooijen and then I customize for my case.
def cp(path)
"current" if request.url.include?(path)
end
<%= link_to "All Posts", posts_path, class: cp(posts_path) %>
Now if my menu bar is /users and my current page is /users/10/post also the link /users is set with "current" class