fturtle
fturtle

Reputation: 375

Get matching route from URL in rails (again)

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.

Upvotes: 6

Views: 4774

Answers (1)

klew
klew

Reputation: 14967

You can use:

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

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

Upvotes: 14

Related Questions