繁体   English   中英

Rails 命名空间路由 - Windows 与 Linux

[英]Rails namespaced routes - Windows vs Linux

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

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

我有一些嵌套模块,并且在 Windows (prod) 和 Mac OS (dev) 上一切正常。

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

最近我从 Mac OS 更改为 Ubuntu 11.04。 一切正常,除了这些嵌套路由。

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

有没有人知道发生了什么? 为什么这个问题只有 Linux?

如果它以这种特定方式影响路由,则不太可能是特定于操作系统的问题。 您是否有任何理由在 controller 名称前加上/ 命名路线通过非常具体来避免大部分混乱,所以不幸的是你没有它们。

两个系统上的 gem 版本可能略有不同,可能非常微妙。

尝试这样的事情

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

或者使用 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

希望这可以帮助

暂无
暂无

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

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