Hello, Is it possible to alter a Rails app''s routing table at runtime? I want to be able to add and remove routes from an admin application. Thanks. Michael --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Michael Allman wrote:> Is it possible to alter a Rails app''s routing table at runtime? I > want to be able to add and remove routes from an admin application.I would put p ''yo'' inside the route map, run the app, and see how often it prints. I don''t know if it''s once per route, once per action, or only at startup time. However, if you need to think outside the route box entirely, I suspect you can use this: map.any_route ''/*paths'', :controller => ''foo'', :action => ''any_action'' Now the system will call any_action with a params[:paths] set to an array of each /path/element/ in an URI. Then you parse and dispatch them yourself. But I can''t think of any reason to add or remove routes in a way that solves an actual web problem... -- Phlip --~--~---------~--~----~------------~-------~--~----~ 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 found that I can just call require ''config/routes'' at the right time in my action to rebuild the entire routing table. That''s good enough for me. Thanks. Michael On Sep 19, 9:57 pm, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Michael Allman wrote: > > Is it possible to alter a Rails app''s routing table at runtime? I > > want to be able to add and remove routes from an admin application. > > I would put p ''yo'' inside the route map, run the app, and see how often it > prints. I don''t know if it''s once per route, once per action, or only at startup > time. > > However, if you need to think outside the route box entirely, I suspect you can > use this: > > map.any_route ''/*paths'', :controller => ''foo'', :action => ''any_action'' > > Now the system will call any_action with a params[:paths] set to an array of > each /path/element/ in an URI. Then you parse and dispatch them yourself. > > But I can''t think of any reason to add or remove routes in a way that solves an > actual web problem... > > -- > Phlip--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---