Hey guys. In Rails 2, is there a way to create a route at run-time? I
want to do this because a gem that I’m writing requires a single
resource route, and I’d prefer that the gem create it at run-time
instead of forcing the user to define the route in routes.rb .
While trying to figure this out, I discovered that calling
ActionController::Routing::Routes.draw do |map|
# my gem’s route here
causes all of the routes in routes.rb to be removed.
I tried copying the routes from ActionController::Routing::Routes into
a new array or hash, then rebuilding them and adding my gem’s route,
but couldn’t get that to work. Also, it’s messy and less than ideal.
So, any suggestions? I’m all ears!