Pat Maddox
2007-Mar-20 20:11 UTC
"reverse" routes - getting a controller and action from a URL
I''m using redirect_to :back in my app in one place. In a couple cases I need to see if the http referrer is a certain controller/action pair, and do something differently based on that. Is there some way to get the url options from a url string? Pat --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yossef Mendelssohn
2007-Mar-20 20:54 UTC
Re: "reverse" routes - getting a controller and action from a URL
Pat, You want to take a look at ActionController::Routing::Routes.recognize_path I don''t know if you have the Pragmatic Agile book, 2nd edition. If so, check out page 398 (chapter 20, "Action Controller: Routing and URLs"). If not, check out this example from my console:>> ActionController::Routing::Routes.recognize_path "/users"=> {:controller=>"users", :action=>"index"}>> ActionController::Routing::Routes.recognize_path "/users/5"=> {:controller=>"users", :action=>"5"}>> ActionController::Routing::Routes.recognize_path "/users/5", :method => :get=> {:controller=>"users", :action=>"show", :id=>"5"}>> ActionController::Routing::Routes.recognize_path "/users/5", :method => :put=> {:controller=>"users", :action=>"update", :id=>"5"}>> ActionController::Routing::Routes.recognize_path "/users", :method => :post=> {:controller=>"users", :action=>"create"} -- -yossef --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---