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.
You can use:
ActionController::Routing::Routes.recognize_path( '/your/url/here', :method => :get )
:method can have :get, :post, :put and :delete
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With