views:

277

answers:

1

Hello. How can I parse url string to hash like

{:controller => 'controller_name', :action => 'action_name', :id => 'id'}

?

+3  A: 

You may be able to use ActionController::Routing::Routes.recognize_path, depending on the format of the URL:

>> ActionController::Routing::Routes.recognize_path("/accounts/1",:method=>:get)`
# {:action=>"show":controller=>"accounts",:id=>"1"}

More info on this blog post

zetetic