I'm a little unclear what you want, but I'm going to assume you mean that given a String
representing a path that maps onto one of our routes, you'd like to get back a String
with the path segment parameters replaced by their identifying keys. You can do this as follows:
def uninterpret(path)
path_params = Rails.application.routes.recognize_path(path)
path_params.each do |key, value|
path.sub!(value, ":#{key}")
end
path
end
I'm sure there are some edge cases unaccounted for there, but that should work for your standard resourceful route.