Skip to content

Instantly share code, notes, and snippets.

@sephraim
Created February 28, 2023 14:51
Show Gist options
  • Save sephraim/483578583271e16b99d17f62f09b5044 to your computer and use it in GitHub Desktop.
Save sephraim/483578583271e16b99d17f62f09b5044 to your computer and use it in GitHub Desktop.
[Get all valid routes in Rails]
routes = Rails.application.routes.routes.map { |r| r.path.spec.to_s }
# *OR* for even more attributes
Rails.application.routes.routes.map { |r| { alias: r.name, path: r.path.spec.to_s, controller: r.defaults[:controller], action: r.defaults[:action] } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment