2012-05-15 167 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」。