Created
July 26, 2011 17:12
-
-
Save shamil614/1107252 to your computer and use it in GitHub Desktop.
Set active or selected links based on request path and link path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def active_link(path, match_top_dir=false) | |
debugger | |
if match_top_dir == true | |
req_path_a = request.path.to_s.split('/') | |
path_a = path.split('/') | |
if req_path_a[1] == path_a[1] | |
return 'selected' | |
end | |
else | |
if path == request.path | |
return "selected" | |
else | |
return nil | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment