Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 237
fturtle Avatar asked Jun 06 '09 16:06

fturtle


1 Answers

You can use:

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

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

like image 79
klew Avatar answered Sep 30 '22 15:09

klew