Created
November 25, 2013 22:31
-
-
Save alaingoldman/7650105 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
def current_path | |
current_url = request.original_url | |
end_of_string = current_url.length | |
regex_index = (Rails.env.production?) ? /.\.com\// : /:\d\d\d\d\// | |
regex_after_index = (regex_index =~ current_url) + 5 # production 7 | |
path= end_of_string - regex_after_index | |
if path == 0 | |
"/" | |
else | |
current_url[-path..-1] | |
end | |
end |
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
current_path = request.fullpath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment