views:

179

answers:

1

Hi,

How can I get hold of the matching route for a url in rails? Given a url, I want to query the respective controller and action. Note, the current page isn't the url in question.

This question has been posed before but wasn't answered.

Cheers.

+3  A: 

You can use:

ActionController::Routing::Routes.recognize_path( '/your/url/here', :method => :get )

:method can have :get, :post, :put and :delete

klew
Brilliant. Thankyou very much.
fturtle