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' }

4 comments:

Kostas said...

This is great! Thanks a lot!

2collegebums said...

Thank you. It's people like you that make coding pleasant.

Anonymous said...

THX!!!!

Lance said...

You are my sunshine. My only sunshine. You make me happy when skies are blue.