2012-05-15 60 views
1

我安装我的路由到命名空间,所以它看起来像路由或轨道错误?

root to: "home#index" 

namespace :users do 
    root to: "profile#index" 
    resources :registrations 
    resources :sessions 
end 

namespace :admin do 
    root to: "base#index" 
end 

rake routes |grep root 
       root  /        home#index 
      admin_root   /admin(.:format)    admin/base#index 
      users_root   /users(.:format)    users/profile#index 

在我的头导航,我有= link_to "home", root_path

一切都在发展方式工作的伟大,但在生产

我完全打破当试图访问会话/注册控制器(用户/会话/新)时得到No route matches {:controller=>"users/home"}

我的头中的root_path尝试获得home控制器users命名空间提前

+0

你可以运行'bundle exec rake routes | grep root'在生产中? –

回答

0

感谢区分每一根路径,并尝试像

root to: "home#index" , :as => home_root 

namespace :users do 
    root to: "profile#index" , :as => users_root 
    resources :registrations 
    resources :sessions 
end 

namespace :admin do 
    root to: "base#index" , :as => admin_root 
end 

使用路径,如:home_root_path,users_root_path,admin_root_path

0

没有在用户命名空间中的家庭控制器中,用户命名空间中有一个配置文件控制器。

你需要users_root_path去“users/profile#index”。

但你说得对,我希望root_path去“home#index”。