Skip to content

Instantly share code, notes, and snippets.

@h3h
Last active August 29, 2015 14:00
Show Gist options
  • Save h3h/11197851 to your computer and use it in GitHub Desktop.
Save h3h/11197851 to your computer and use it in GitHub Desktop.
Getting the first segments of currently defined static routes
Rails.application.routes.set.
map { |r| r.optimized_path[1..-1].split('/').first }.
uniq.
compact.
reject { |s| s.include?('*') || s.include?(':') }
@h3h
Copy link
Author

h3h commented Apr 22, 2014

Example output:

=> ["admins", "home", "about", "privacy", "terms", "unsubscribe", "404", "500", "feed",
    "invite", "join", "sign-in", "sign-out", "account", "users", "rails"]

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