[Rails] Adding routes via a plugin...
Steve Longdo
steve.longdo at gmail.com
Wed Feb 8 17:06:59 GMT 2006
I have a plugin that I am working on that will as part of its distribution
contain a controller. I would like to be able to add a route for it in the
plugin's init.rb so that when the plugin is loaded, the route will
automatically be registered without having to force the user to edit
routes.rb or even make a rake task to do it for them.
I saw the following code in one of the SVN rails/plugin modules:
ActionController::Routing::RouteSet.send :include, RestfulRoutes
, but it just includes a module with a method to add named routes.
I would like to actually add a route to the routeset automatically. I tried
using variations on the above to directly call named_route from my plugin's
init.rb, but I have not been able to get it to work.
Also I notice that there is a reload method in the routing.rb file that will
clear out the current named routes and read in the routes.rb file again.
Does this get called internally somewhere by Rails? I guess I am wondering
that even if I figure out a way to add my route dynamically, Rails might
call the reload method after my plugin is loaded and my route woud go away
anyway.
Should I just pursue a rake task as part of the install to add the route
into the routes.rb file, or can what I want to do be accomplished with Rails
1.0?
Thanks,
-Steve
http://www.stevelongdo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060208/0be0759b/attachment.html
More information about the Rails
mailing list