Invoke a route directly from a url

I was wondering whether it would be possible to invoke a route directly
from inside rails from a url.
In other words, I have a url
http://localhost:3000/webdav/number1/folder’ and I don’t want to have
to go through the trouble of parsing it manually. Is there some rails
method I can call to parse it, giving an array of params?

Alex,

Try this method (adapted from the assert_routing tests):

def path_parameters_from_path(path, request_method)
request = ActionController::TestRequest.new({}, {}, nil)
request.env[“REQUEST_METHOD”] = request_method.to_s.upcase if
request_method
request.path = path
ActionController::Routing::Routes.recognize(request)
request.path_parameters
end

Use it like this…

path_parameters_from_path("/books/1", :get)
path_parameters_from_path("/books/1", :put)

-christos