Thursday, July 03, 2008

Rails: Get controller route hash from url string

This is somewhat uncommon, but to get the routing hash from a URL string:

ActionController::Routing::Routes.recognize_path('/users/1')
# => {:controller => 'users', :action => 'show', :id => '1' }