devise user_root_path在生产中获得404’d但不是dev?

很奇怪,我知道但在生产中使用user_root_path不起作用。 当我点击链接myapp.com/user我得到一个404页面。

日志文件不显示吐出但尝试失败:

 Started GET "/user" for 123.125.146.23 at 2011-01-19 19:40:45 +0000 ActionController::RoutingError (uninitialized constant User::UsersController): 

现在,查看有关此单位化常量的唯一方法是打开rails c并将常量输入控制台。 这是发生的事情:

 ruby-1.9.2-p136 :005 > User::UsersController (irb):5: warning: toplevel constant UsersController referenced by User::UsersController => UsersController 

现在一些挖掘发现这个顶级警告可能会搞乱它。 但日志说bubkiss。

所以我改变了路线文件:

  devise_for :users namespace :user do root :to => "users#index" end resources :subdomains match '/user' => 'users#index' 

至:

 devise_for :users namespace :user do root :to => "subdomains#index" end resources :subdomains match '/user' => 'users#index', :controller => :users 

想法可能是生产环境不喜欢用户#index …所以我把它改成了子域名#index。 我可以得/子域没问题。 所以实际页面会显示,这是捏造的路线……任何想法?

设置:rails 3.0.3,设计1.1.5(并且升级了1.1.3,同样的问题)

我用了

 devise_for :users do match 'user' => "users#index", :as => :user_root, :constraints => { :domain => SITE_DOMAIN} end 

在您的每个development.rb或production.rb文件中,您将拥有SITE_DOMAIN常量,如下所示:

 ::SITE_DOMAIN = "lvh.me" #in development.rb I was using subdomains with the helpful lvh.me google it. 

或者在production.rb

 ::SITE_DOMAIN = "mydomain.com" 

我再次需要子域名,所以这对我有用。

设计维基不适合我。 一旦我有时间,我也会更新,或提交一张票,但这只是那些需要它的谷歌果汁。

如果要为路由命名空间,则还需要命名控制器。

将controllers / users_controller.rb移动到controllers / user / users_controller.rb并编辑它以添加到模块中:

 class User::UsersController < ApplicationController end 

但我的猜测是你实际上并不意味着在路线中使用命名空间。

我和/用户在生产中给出了相同的问题。 这是我最终得到的解决方案,我认为这比解决路线更简单。 在ApplicationController中放:

 def after_sign_in_path_for(resource) stored_location_for(:user) || landing_welcome_path end 

有人可以解释环境如何影响rails 3中的路由吗?