Namespaced controllers only work with namespaced routes
-
Ian White
Yes, this feature is designed with the :namespace option in mind. I can see that your intended use should be supported though.
How about an option :extract_namespace, which defaults to true, but could be turned off
class Events::Participants < ApplicationController resources_controller_for :participants, :extract_namespace => false end -
Ian White
I think that #namespace_segments should be more selective and only assume that the namespace prefix is in the path if it > is immediately followed by the current segment. See the implementation below.
I don't think this approach will work in the case where a controller is invoked with a wildcard nesting path (a common use case)
map.namespace :admin do |admin| admin.resources :forums admin.resources :users, :has_many => :forums end class Admin::ForumsController resources_controller_for :forums # this controller handles /admin/forums, and /admin/users/:id/forums endWhen requesting
'/admin/forums/1'your proposal works fine, but when requesting'/admin/users/1/forums'it will break as the namespace won't be processed.So, would you be happy for an option which turns namespacing off completely? (as outlined above)
-
Ian White
btw. namespace processing is required for routes created with :namespace, because of the name prefixes routing creates for named routes.
-
sserdyuk
':extract_namespace => false' seems like a bad hack to me, especially because all this specified in routes. Have you ever considered aliasing ActionController::Routing::Routes#draw and getting the real picture from the source? I just tried it in 2.3.4 and aliasing from plugin's init.rb worked.
-
Ian White
Hi,
I have been trying to move away from relying on rails routing internals for rc, since these are part of the private API, and subject to change resulting in weird breakage.
But, perhaps my approach is not the same as yours. Could you make a fork on github with the changes you mention above, as a proof of concept please?
Cheers,
Ian
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.