Skip to content

Instantly share code, notes, and snippets.

View amerritt14's full-sized avatar

Andrew Merritt amerritt14

  • Wilmington
  • 10:47 (UTC -04:00)
View GitHub Profile
@bantic
bantic / rails_route_recognizer.rb
Last active September 9, 2022 12:22
Programmatically list all routes (/paths) from within a rails app.
class RouteRecognizer
attr_reader :paths
# To use this inside your app, call:
# `RouteRecognizer.new.initial_path_segments`
# This returns an array, e.g.: ['assets','blog','team','faq','users']
INITIAL_SEGMENT_REGEX = %r{^\/([^\/\(:]+)}
def initialize