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
Community
  • 1
  • 1
Thilo
  • 17,565
  • 5
  • 68
  • 84

1 Answers1

8

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

Rails.application.routes.recognize_path('/accounts/new', {:method => :get})
dsetton
  • 816
  • 8
  • 15