1

This is basically a rails 3 version of this question. Short of parsing it myself, how can I get the components (controller, action, parameters) from a URL string?

The method ActionController::Routing::Routes#recognize_path has been deprecated, and I can't get the one it's been replaced with to work the same way:

1.9.3p125 :019 > ActionDispatch::Routing::RouteSet.recognize_path('/accounts/new', {:method => :get})
NoMethodError: undefined method `recognize_path' for ActionDispatch::Routing::RouteSet:Class

which makes sense since it's not a static method. Looking at the source didn't enlighten me either. Any pointers would be welcome.

EDIT:

ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]
Rails 3.2.3

1 Answer 1

8

This works for me (Ruby 1.9.2, Rails 3.1.0):

Rails.application.routes.recognize_path('/accounts/new', {:method => :get})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.