简体   繁体   中英

Rails namespaced routes - Windows vs Linux

I'm working on an old client application running under Rails 2.3.11 on Windows Server 2003. All the application relies on a simple catch-all route (Hell yeah:) :

map.connect ':controller/:action/:id'

I have some nested modules and everything is working fine on Windows (prod) and Mac OS (dev).

url_for(:controller=>'/settings/users', :action=>:index)
#=> Settings::Users#index

Recently I changed from Mac OS to Ubuntu 11.04. Everything works, except these nested routes.

url_for(:controller=>'/settings/users', :action=>:index)
#=> Settings#users

Does anyone have a clue about what is going on? Why is this problem Linux only?

It's not very likely that this is an OS-specific problem if it affects the routing in such a specific way. Is there any reason you're prefixing the controller name with / ? Named routes avoid most of this mess by being very specific, so it's unfortunate you're left without them.

There's probably a slight difference in gem versions on the two systems, maybe something very subtle.

try somehting like this

 map.namespace :settigns do |settings|
   settings.connect '/:controller/:action/:id
 end

or something using map.namespace, that is how I do controllers in a module, except its different types of routes

 map.namespace :admin do |admin|
   admin.resources :reports, :only => [:new, :create ]
   admin.connect 'reports/generate/:action/*rest', :controller => 'reports'
   admin.resources :approval, :controller => 'approval', :only => [ :index, :create ] 
   admin.resource :home, :controller => 'home' 
 end

hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM