Hey folks. I have a rails controller which is filtering search results for access control. The search results are typically URLs into the rest of the rails app. I''m finding it would simplify the grotty code which is accumulating if I could manually invoke the router. That is to say, if I could send something a URI path string and get back the hash of controller, action, and params that would be invoked if this had been a real request. Is this possible? - donald --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 10/3/07, Ball, Donald A Jr (Library) <donald.ball-GjtI+QwuxAR68HQyEA6aog@public.gmane.org> wrote:> > Hey folks. I have a rails controller which is filtering search results > for access control. The search results are typically URLs into the rest > of the rails app. I''m finding it would simplify the grotty code which is > accumulating if I could manually invoke the router. That is to say, if I > could send something a URI path string and get back the hash of > controller, action, and params that would be invoked if this had been a > real request. Is this possible?I''m not sure how to do it, but this may be of some help: http://weblog.jamisbuck.org/2006/10/4/under-the-hood-route-recognition-in-rails --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> I''m not sure how to do it, but this may be of some help: > > http://weblog.jamisbuck.org/2006/10/4/under-the-hood-route-recognition-in-rails Thanks, that does illuminate much. This snippet works in the console: result_params ActionController::Routing::Routes.recognize_path(uri.path) but it throws a NameError when I try it in a controller action: uninitialized constant ActionWebService::Dispatcher::ActionController::Routing I''ve tried a few different flavors of the fully qualified class name but haven''t found one that works yet. Any suggestions? - donald --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Thanks, that does illuminate much. This snippet works in the console: > > result_params > ActionController::Routing::Routes.recognize_path(uri.path) > > but it throws a NameError when I try it in a controller action: > > uninitialized constant > ActionWebService::Dispatcher::ActionController::Routing > > I''ve tried a few different flavors of the fully qualified > class name but haven''t found one that works yet. Any suggestions?Criminy, I got it to work by the following mechanism: class << self def recognize_path(path) ActionController::Routing::Routes.recognize_path(path) end end def index ... result_params = self.class.recognize_path(uri.path) ... end Any notion why this works when I wrap it up in a metaclass method?? - donald --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---