Skip to content

Instantly share code, notes, and snippets.

@alaingoldman
Created November 25, 2013 22:31
Show Gist options
  • Save alaingoldman/7650105 to your computer and use it in GitHub Desktop.
Save alaingoldman/7650105 to your computer and use it in GitHub Desktop.
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
current_path = request.fullpath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment