简体   繁体   English

Rails 命名空间路由 - Windows 与 Linux

[英]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:) :我正在开发一个在 Windows Server 2003 上运行在 Rails 2.3.11 下的旧客户端应用程序。所有应用程序都依赖于一个简单的包罗万象的路线(地狱是的:):

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

I have some nested modules and everything is working fine on Windows (prod) and Mac OS (dev).我有一些嵌套模块,并且在 Windows (prod) 和 Mac OS (dev) 上一切正常。

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

Recently I changed from Mac OS to Ubuntu 11.04.最近我从 Mac OS 更改为 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?为什么这个问题只有 Linux?

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 / ?您是否有任何理由在 controller 名称前加上/ 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.两个系统上的 gem 版本可能略有不同,可能非常微妙。

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 的东西,这就是我在模块中做控制器的方式,除了它不同类型的路由

 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希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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