Skip to content

Instantly share code, notes, and snippets.

@ndizazzo
Last active December 17, 2015 05:38
Show Gist options
  • Save ndizazzo/5559019 to your computer and use it in GitHub Desktop.
Save ndizazzo/5559019 to your computer and use it in GitHub Desktop.
Provides an array of your root-level rails routes without leading slashes.
routes = Rails.application.routes.routes.map { |route| route.path.spec.to_s }.each { |r| r.replace(r.match(/^\/(\w+)/).to_s).tr!('/', '') }.delete_if(&:empty?).uniq!
@ndizazzo
Copy link
Author

=> ["assets",
"users",
"sessions",
"signup",
"login",
"logout",
"rails"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment