Hello all, While looking into a issue posted on the Lockdown forum I came across the following: ActionController::Routing::Routes.recognize_path "/users/1/edit" => {:action=>"1", :controller=>"users", :id=>"edit"} Notice the :action and :id value swap. Is this a mis-use of the recognize_path method...In other words, is it intended to be used with named routes only? Or is this just a simple bug that needs to be fixed? thanks, andy -- Andrew Stone --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Mon, Aug 4, 2008 at 7:36 PM, Andrew Stone <stonelists@gmail.com> wrote:> Hello all, > > While looking into a issue posted on the Lockdown forum I came across the > following: > > ActionController::Routing::Routes.recognize_path "/users/1/edit" => > {:action=>"1", :controller=>"users", :id=>"edit"} > > Notice the :action and :id value swap. > > Is this a mis-use of the recognize_path method...In other words, is it > intended to be used with named routes only? Or is this just a simple bug > that needs to be fixed?Technically it might not even be a bug, it seems to be matching on :controller/:action/:id. What do you have in your routes file? But even more fundamentally, why are you calling recognize_path directly? Perhaps there''s an easier way?> thanks, > andy > > -- > Andrew Stone > > > >-- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
> > Technically it might not even be a bug, it seems to be matching on > :controller/:action/:id. What do you have in your routes file? > > But even more fundamentally, why are you calling recognize_path > directly? Perhaps there''s an easier way? > >If there is an easier way, that would be great. The routes file contains just a simple map.resources :users. It''s being used in lockdown for the case when someone passes in a named route to the link_to method, such as: link_to "Login", login_path I need to get the actual path to either grant/deny the ability to show the link. I was using recognize_path to return the hash related to the named route. Does that explain it? Let me know if more info is needed. thanks, andy -- Andrew Stone --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
> > > If there is an easier way, that would be great. > > The routes file contains just a simple map.resources :users. > > It''s being used in lockdown for the case when someone passes in a named > route to the link_to method, such as: > > link_to "Login", login_path > > I need to get the actual path to either grant/deny the ability to show the > link. I was using recognize_path to return the hash related to the named > route. > > Does that explain it? Let me know if more info is needed. > >To add a little more... If the request is http://localhost:3000/login and map.login, :controller => "sessions", :action => "destroy" I need to know that /login => {:controller => "sessions", :action => "destroy} when the request is made. So, it''s just not the link_to call. thanks again, andy -- Andrew Stone --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
map.login, :controller => "sessions", :action => "destroy"> >ooops. typing too fast: :action => "new" for login. doh! -- Andrew Stone --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
> If there is an easier way, that would be great. > > The routes file contains just a simple map.resources :users.Does the /users/1/edit url actually *go* to the right place when you access it?> It''s being used in lockdown for the case when someone passes in a named > route to the link_to method, such as: > > link_to "Login", login_path > > I need to get the actual path to either grant/deny the ability to show the > link. I was using recognize_path to return the hash related to the named > route. > > Does that explain it? Let me know if more info is needed.I assume map.connect '':controller/:action/:id'' is either removed or comes *after* the map.resources call? If it''s the other way around then this if functioning as intended.> thanks, > andy > > -- > Andrew Stone > > > >-- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Mon, Aug 4, 2008 at 4:07 PM, Michael Koziarski <michael@koziarski.com>wrote:> > > If there is an easier way, that would be great. > > > > The routes file contains just a simple map.resources :users. > > Does the /users/1/edit url actually *go* to the right place when you access > it? >Yes it does.> > > It''s being used in lockdown for the case when someone passes in a named > > route to the link_to method, such as: > > > > link_to "Login", login_path > > > > I need to get the actual path to either grant/deny the ability to show > the > > link. I was using recognize_path to return the hash related to the named > > route. > > > > Does that explain it? Let me know if more info is needed. > > I assume map.connect '':controller/:action/:id'' is either removed or > comes *after* the map.resources call? If it''s the other way around > then this if functioning as intended. > >map.connect '':controller/:action/:id'' is at the end of my routes file. This is the way it should be, right? -- Andrew Stone --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
> Yes it does.Well that''s very strange...> map.connect '':controller/:action/:id'' is at the end of my routes file. This > is the way it should be, right?The only other thing I can think of is the request method, which is also something that affects route matching. you may need to provide recognize_path with more information in the enviroment hash to make sure it matches correctly. If you can reproduce this in a tiny test app, and upload it to lighthouse, people may be able to give you a hand. Similarly if you can make it fail in the routing tests that''d make things easier. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---