Created
July 7, 2012 08:36
-
-
Save jasoncodes/3065508 to your computer and use it in GitHub Desktop.
Named route name from path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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