Skip to content

Instantly share code, notes, and snippets.

@jasoncodes
Created July 7, 2012 08:36
Show Gist options
  • Save jasoncodes/3065508 to your computer and use it in GitHub Desktop.
Save jasoncodes/3065508 to your computer and use it in GitHub Desktop.
Named route name from path
path = '/products/42/edit'
params = Rails.application.routes.recognize_path path
route = nil; Rails.application.routes.formatter.send(:match_route, nil, params) { |r| route ||= r }
p route.name # returns "edit_product"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment