Created
February 6, 2009 16:37
-
-
Save scharfie/59485 to your computer and use it in GitHub Desktop.
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
# helpers/path_helper.rb | |
module PathHelper | |
def path_as_array | |
path = (request.path_info || '').gsub(/^#{Bones.base}/, '') | |
path = path.split('/').map {|e| e.empty? ? nil : e}.compact | |
end | |
def current_path(depth=-1) | |
File.join('/', *[path_as_array[0..depth]]) | |
end | |
def relative_path(path, depth=-1) | |
File.expand_path(File.join(current_path(depth), path)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment