Hi all, I was wondering if it was at all possible to add routes without destroying all the old routes that were defined in config/routes.rb. I have been able to make new routes using ActionContoller::Routing::Routes.draw do |map| ... end , but doing so wipes out all the old routes that I had defined. Do I have to reiterate defining all the old routes in the plugin, but how? Thanks in advance, Luke -- Luke Amdor luke-Hk3lrmVzaNfBeN7rVTv1SdHuzzzSOjJt@public.gmane.org /usr/bin/fortune | I woke up a feelin'' mean went down to play the slot machine the wheels turned round, and the letters read "Better head back to Tennessee Jed" -- Grateful Dead
If anyone wants to know, here''s how I did it. All I did was make
ActionContoller::Routing::Routes#routes readable and then just put the
old routes back in like so:
class <<ActionController::Routing::Routes
attr_accessor :routes
end
old_routes = ActionController::Routing::Routes.routes
ActionController::Routing::Routes.draw do |map|
map.connect ''caboose'', :controller =>
''caboose'',:action => ''login''
old_routes.each do |route|
map.routes << route
end
end
It works pretty well so far. All routes are are preserved and named
routes work as well. You can also work through the routes and put your
routes in as you would like as well, but in my case, I just wanted mine
first.
Luke
On Mon, Dec 12, 2005 at 02:03:38PM -0600, Luke Amdor
wrote:> Hi all,
>
> I was wondering if it was at all possible to add routes without
> destroying all the old routes that were defined in config/routes.rb.
> I have been able to make new routes using
> ActionContoller::Routing::Routes.draw do |map| ... end , but doing so
> wipes out all the old routes that I had defined. Do I have to reiterate
> defining all the old routes in the plugin, but how? Thanks in advance,
>
> Luke
> --
> Luke Amdor
> luke-Hk3lrmVzaNfBeN7rVTv1SdHuzzzSOjJt@public.gmane.org
>
> /usr/bin/fortune |
>
> I woke up a feelin'' mean
> went down to play the slot machine
> the wheels turned round,
> and the letters read
> "Better head back to Tennessee Jed"
> -- Grateful Dead
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
Luke Amdor
luke-Hk3lrmVzaNfBeN7rVTv1SdHuzzzSOjJt@public.gmane.org
/usr/bin/fortune |
The following statement is not true. The previous statement is true.
I want to add my own route in a plugin. Luke Amdor demonstrated how it could be done a few weeks back. http://article.gmane.org/gmane.comp.lang.ruby.rails/34524 But as far as I can tell (I haven''t tried it), this won''t work in Rails 1.0 because of the following change that DHH made. http://dev.rubyonrails.org/changeset/2967 This change means that routes.rb is now processed AFTER the plugin code and so any routes you define in the plugin code would be lost. I think this change was supposed to make adding routes easier but I can''t figure out a good way of doing it. Any ideas? James
Nevermind! A patch that does the trick has been submitted. (-: http://dev.rubyonrails.org/ticket/3202 James On Thu, 5 Jan 2006 14:07:30 +0000 James Le Cuirot <chewi@aura-online.co.uk> wrote:> I want to add my own route in a plugin. Luke Amdor demonstrated how it > could be done a few weeks back. > > http://article.gmane.org/gmane.comp.lang.ruby.rails/34524 > > But as far as I can tell (I haven''t tried it), this won''t work in > Rails 1.0 because of the following change that DHH made. > > http://dev.rubyonrails.org/changeset/2967 > > This change means that routes.rb is now processed AFTER the plugin > code and so any routes you define in the plugin code would be lost. I > think this change was supposed to make adding routes easier but I > can''t figure out a good way of doing it. Any ideas? > > James